JDK8 ArrayList源码分析

本文详细分析了JDK8中ArrayList的实现,包括ArrayList的类注释、元素存储不被序列化的特性、内部数组的扩容策略以及subList方法的工作原理。文章指出ArrayList的迭代器是fail-fast的,并提醒在并发修改时要注意其行为。此外,还讨论了如何在添加大量元素前通过ensureCapacity优化容量,以及ArrayList的子列表操作仅提供部分内容的索引访问,不支持直接修改内部结构。
摘要由CSDN通过智能技术生成

1. ArrayList类注释翻译

Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list. (This class is roughly equivalent to Vector, except that it is unsynchronized.) ArrayList是List接口的可变数组实现。ArrayList实现了所有可选的list操作,并且允许所有元素,包括null。ArrayList除了实现List接口以外,这个类还提供了操控数组(数组在内部被用来存储list)大小的方法。(ArrayList大体上等同于Vector,除了ArrayList是非线程安全的。)

The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation. 执行size、isEmpty、get、set、iterator以及list

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值