给楼主整理了一下代码:
DoubtAboutCollection dac1 = new DoubtAboutCollection();
dac1.setDoubtInt(1);
dac1.setDoubtString("abc1");
就等同于 DoubtAboutCollection dac1 = new DoubtAboutCollection(1,"abc");
DoubtAboutCollection dac1 = new DoubtAboutCollection(1,"abc"); //楼主加入集合的都是new DoubtAboutCollection对象,所以打印的是对象的内存地址,DoubtAboutCollection@de6ced。DoubtAboutCollection指对象的名称,de6ced对此昂内存地址所演算出来的哈希值。内存地址本身是不能打印的
DoubtAboutCollection dac2 = new DoubtAboutCollection(2,"abc2");
DoubtAboutCollection dac3 = new DoubtAboutCollection(3,"abc3");
Collection<DoubtAboutCollection> coll = new ArrayList<DoubtAboutCollection>();
coll.add(dac1);
coll.add(dac2);
coll.add(dac3);
sop(coll); |