![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java基础
Catherine_LW
这个作者很懒,什么都没留下…
展开
-
Java ArrayList扩容 源码
ArrayList每次扩容是原数组大小的1.5倍 Arraylist的源码分析: 为何扩容? /** * Default initial capacity.默认长度为10 */ private static final int DEFAULT_CAPACITY = 10; public boolean add(E e) { ensureCapacityInternal(size + 1); // Increments modCount!! 向数原创 2021-07-12 22:47:34 · 74 阅读 · 0 评论 -
128陷阱
128陷阱就是:为对于Integer,在(-128,128]之间只有固定的256个值,为了避免多次创建对象,事先创建好一个大小为256的Integer数组SMALL_VALUES,如果值在这个范围内,就可以直接返回创建好的对象。对于不在这个范围内的比较,会自动比较对象,而不是比较基本数据。原创 2021-07-10 23:45:44 · 145 阅读 · 0 评论