public class ConcatArrays {Output
public static void main(String[] args) {
String[] t1 = {"1","2","3"};
문자열[] t2 = {"4","5","6"};
문자열[] t12 = 새 문자열[t1.length+t2.length];
/*연결*/
for(int i = 0 ; i < t1.length; i++)
t12[i]=t1[i];
for(int i = 0 ; i < t2.length; i++)
//인덱스에서 t12로 복사를 계속합니다
//중지한 t1
t12[i+t1.length]=t2[i];
for(int i = 0 ; i < t12.length; i++)
System.out.println(t12[i]);
}
}
1
2
3
4
5
6
public class ConcatArrays {Output
public static void main(String[] args) {
char[] t1 = {'a', 'b','c'};
문자[] t2 = {'d','e','f'};
문자[] t12 = 새 문자[t1.length+t2.length];
//첫 번째 배열의 복사본
System.arraycopy(t1, 0, t12, 0, t1.length);
//두 번째 배열의 복사본 array
System.arraycopy(t2, 0, t12, t1.length, t2.length);
for(int i = 0 ; i < t12.length; i++)
System.out.println(t12[i]);
}
}
aReferences
b
c
d
e
f
Please disable your ad blocker and refresh the window to use this website.