AbstractCollection源代码的一个小问题
我在看AbstractCollection的源代码时,看到这么一个方法:
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[");
Iterator<E> i = iterator();
boolean hasNext = i.hasNext(); //为什么不直接用i.hasNext? 这样做有什么好处么?还是有其他原因?
while (hasNext) {
E o = i.next();
buf.append(o == this ? "(this Collection)" : String.valueOf(o));
hasNext = i.hasNext();
if (hasNext) //这边也是
buf.append(", ");
}
buf.append("]");
return buf.toString();
}
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[");
Iterator<E> i = iterator();
boolean hasNext = i.hasNext(); //为什么不直接用i.hasNext? 这样做有什么好处么?还是有其他原因?
while (hasNext) {
E o = i.next();
buf.append(o == this ? "(this Collection)" : String.valueOf(o));
hasNext = i.hasNext();
if (hasNext) //这边也是
buf.append(", ");
}
buf.append("]");
return buf.toString();
}
...全文
相关推荐
java实现搜索引擎源代码
通过AbstractCollection和FileSystemCollection实现文
javasrc源码-java_src_study:javasrc源代码阅读
该项目聚焦于Java集合体系的核心抽象类源码分析,涵盖AbstractCollection、AbstractList、AbstractMap、AbstractQueue和AbstractSequent
物理引擎APE中文帮助
APE的官方网址为http://www.cove.org/ape,下载地址为http://www.cove.org/ape/ape_a045.zip,包含两个demo、API、SWC文件和源代码。
APE物理引擎中文API
**AbstractCollection**:这是一个抽象基类,作为Group和Composite两类的父类。它不直接被实例化,而是用于管理粒子和约束的集合。
collection:[只读] PHP集合库(列表,集合,映射,队列和堆栈)
本文介绍了PHP中集合相关类和接口的设计,包括AbstractCollection抽象类、AbstractList抽象类及ArrayList类的功能实现。还详细说明了Collection接口及其常用方


Java SE
