代码:
import java.util.ArrayList;
public class main {
public static void main(String[] args) {
ArrayList List1 = new ArrayList();
for(int i = 0; i<10;i++) {
List1.add(i);
}
System.out.println("List1:" + List1);
ArrayList List2 = new ArrayList();
List2.addAll(List1);
System.out.println("List2:" + List2);
}
}
结果: