本帖最后由 Super_Class 于 2013-5-22 16:54 编辑
public String toString() {
Iterator<E> i = iterator();
if (! i.hasNext())
return "[]";
StringBuilder sb = new StringBuilder();
sb.append('[');
for (;;) {
E e = i.next();
sb.append(e == this ? "(this Collection)" : e);//这里的e ==this怎么理解?或者说怎么实现sb.append("this Collection").
if (! i.hasNext())
return sb.append(']').toString();
sb.append(", ");
}
} |