ArrayList

关键点:

>>扩容每次扩容1.5倍

集合源码阅读——ArrayList

>>modcount的作用

  >>ArrayList的父类AbstractList的成员变量

 

集合源码阅读——ArrayList

  >>ArrayList中的许多方法都会出现modcount++的操作

 集合源码阅读——ArrayList

>>ArrayList中的迭代器,返回一个Itr类型的对象

  >>modCount在操作ArrayList的时候会自增, 用来记录操作的次数。

  >>父类AbstractList中的expectedModCount在new出迭代器的时候被初始化为和modCount一样的值了,在迭代器中如果操作了列表,则会改变modCount,如果modCount和expectedModCount的值不一样(其他线程操作了列表,改变了modCount的值),则会在checkForComodification()方法中,抛出ConcurrentModificationException异常了。

集合源码阅读——ArrayList

集合源码阅读——ArrayList

集合源码阅读——ArrayList

集合源码阅读——ArrayList

 

相关文章:

  • 2022-12-23
  • 2021-05-11
  • 2021-07-01
  • 2022-12-23
  • 2021-11-05
  • 2021-10-31
  • 2021-10-18
猜你喜欢
  • 2022-01-08
  • 2021-09-25
  • 2021-10-28
  • 2021-09-17
  • 2021-07-13
  • 2021-09-16
相关资源
相似解决方案