ThinkingInJava持有对象(Containers in Depth)读后总结
?
Collections.nCopies(4, new StringAddress("Hello")));//复制4份Collections.fill(list, new StringAddress("World!"));//替换容器中所有对象?
// Make an array from the List:Object[] array = c.toArray();// Make a String array from the List:String[] str = c.toArray(new String[0]);
List<String> list = Arrays.asList("A B C D E F G H I J K L".split(" "));test("Modifiable Copy", new ArrayList<String>(list));test("Arrays.asList()", list);test("unmodifiableList()",Collections.unmodifiableList(new ArrayList<String>(list)));
@Overridepublic int compareTo(Ex11 o) { int res = this.count - o.count; return res < 0 ? -1 : (res == 0 ? 0 : 1);}??
final Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); ?
?
?
由所有HashMap类的“collection?视图方法”所返回的迭代器都是快速失败的:在迭代器创建之后,如果从结构上对映射进行修改,除非通过迭代器本身的?remove?方法,其他任何时间任何方式的修改,迭代器都将抛出?ConcurrentModificationException。
?
?
18. Holding references
?
?
?