package work.before_info;
import java.util.ArrayList;
import java.util.*;
public class Test {
public Test(){}
static void print(ArrayList al){
al.add(2);
al = new ArrayList();
al.add(3);
al.add(4);
}
public static void main(String[] args) {
Test test = new Test();
ArrayList al = new ArrayList();
al.add(1);
System.out.println(al);
print(al);
System.out.println(al);
System.out.println(al.get(1));
}
}
请问为什么print语句之前输出的al是[1]
print语句之后输出的al是[1,2]
以及去掉print语句则报错呢?