class Data {
int val;
}
public class Test3 {
public static void main(String args[]) {
Data data = new Data();
ArrayList<Data> list = new ArrayList<Data>();
for (int i = 100; i < 103; i++) {
data.val = i;
list.add(data);
}
for (Data d : list) {
System.out.println(d.val);
}
}
}
运行结果都是3个102,为什么啊 不懂 |
|