标签:icc data- vlc idc for nis 结构 wot 三次
阿里java开发手册已经发表,很多都值得认真研究思考,看到零度的思考题,没忍住研究了一下。
List<String> list = Lists.newArrayList(); list.add("1"); list.add("2"); Iterator var2 = list.iterator(); while(var2.hasNext()) { String num = (String)var2.next(); if("2".equals(num)) { list.remove(num); } }
2. ArrayList中的Iterator考察
内部类Itr的主要函数说明
hasNext()函数
return cursor != size;
checkForComodification()函数
if (modCount != expectedModCount) throw new ConcurrentModificationException();
checkForComodification(); int i = cursor; if (i >= size) throw new NoSuchElementException(); Object[] elementData = ArrayList.this.elementData; if (i >= elementData.length) throw new ConcurrentModificationException(); cursor = i + 1; return (E) elementData[lastRet = i];
remove()函数
if (lastRet < 0) throw new IllegalStateException(); checkForComodification(); try { ArrayList.this.remove(lastRet); cursor = lastRet; lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
3. 结合代码分析反例
4. 为什么正例就不会出现这种问题
标签:icc data- vlc idc for nis 结构 wot 三次
原文地址:http://www.cnblogs.com/sqdmydxf/p/7746958.html