本帖最后由 袁银凤 于 2013-8-14 23:05 编辑
- import java.util.ArrayList;
- class Data {
- int val;
- }
- public class Test {
- 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);
- }
- }
- }
复制代码 运行结果都是102,有点迷糊,望前辈们给醍醐灌顶一下! |