https://bong-f.tistory.com/256
List<String> a = new ArrayList(복사하려는리스트);
private static void useArraysClass1() {
int[] arr1 = { 1, 2, 3};
int[] copiedArr1 = Arrays.copyOf(arr1, 5);
int[] copiedArr2 = Arrays.copyOf(arr1, 2);
System.out.println(Arrays.toString(copiedArr1)); // [1, 2, 3, 0, 0]
System.out.println(Arrays.toString(copiedArr2)); //[1, 2]
}
private static void useArraysClass2() {
int[] arr = { 1, 2, 3, 4, 5};
int[] copied1 = Arrays.copyOfRange(arr, 1, 3); // [2, 3]
int[] copied2 = Arrays.copyOfRange(arr, 1, 10); // [2, 3, 4, 5, 0, 0, 0, 0, 0]
System.out.println(Arrays.toString(copied1));
System.out.println(Arrays.toString(copied2));
}
https://docs.oracle.com/javase/7/docs/api/java/lang/System.html
public static void arraycopy(Object src,
int srcPos,
Object dest,
int destPos,
int length)
private static void useSystemClass() {
int[] arr1 = { 1, 2, 3};
int[] arr2 = { 4, 5};
int[] arrResult = new int[5];
System.arraycopy(arr1, 0, arrResult, 0, 2);
System.out.println(Arrays.toString(arrResult)); // [1, 2, 0, 0, 0]
System.arraycopy(arr2, 0, arrResult, 1, 2);
System.out.println(Arrays.toString(arrResult)); // [1, 4, 5, 0, 0]
}