当前位置: 首页 > news >正文

php网站建设毕业论文营销宣传图片

php网站建设毕业论文,营销宣传图片,织梦做的相亲网站,做一手房产中介用什么网站好了解 ArrayList 在 Java 中常用集合类之间的关系如下图所示: 从图中可以看出 ArrayList 是实现了 List 接口,并是一个可扩容数组(动态数组),它的内部是基于数组实现的。它的源码定义如下: public class A…

了解 ArrayList

在 Java 中常用集合类之间的关系如下图所示:

在这里插入图片描述

从图中可以看出 ArrayList 是实现了 List 接口,并是一个可扩容数组(动态数组),它的内部是基于数组实现的。它的源码定义如下:

public class ArrayList<E> extends AbstractList<E>implements List<E>, RandomAccess, Cloneable, java.io.Serializable{
}
  • ArrayList 可以实现所有可选择的列表操作,允许所有的元素,包括空值。ArrayList 还提供了内部存储 List 的方法,它能够完全替代Vector,只有一点例外,ArrayList 不是线程安全的容器。

  • ArrayList 有一个容量的概念,这个数组的容量(size)就是 List 用来存储元素的容量。

  • ArrayList 不是线程安全的容器,如果多个线程中至少有两个线程修改了 ArrayList 的结构的话就会导致线程安全问题,作为替代条件可以使用线程安全的 List,应使用 Collections.synchronizedList

    List list = Collections.synchronizedList(new ArrayList<>());
    
  • ArrayList 具有 fail-fast 快速失败机制,能够对 ArrayList 作出失败检测。当在迭代集合的过程中该集合在结构上发生改变的时候,就有可能会发生 fail-fast,即抛出ConcurrentModificationException异常。

通过源码分析 ArrayList 的扩容机制

当使用空参构造器进行创建 ArrayList 的时候,实际上给 elementData 初始化赋值的是一个空数组 {}

//数组列表的大小(包含的元素数),初始化为 0
private int size;
//存储数组列表元素的数组缓冲区。
transient Object[] elementData;
//默认初始化容量为10
private static final int DEFAULT_CAPACITY = 10;
//默认空数组
private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {};
//使用空参构造器创建 ArrayList 时,实际上初始化赋值的是一个空数组
public ArrayList() {this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
}

当首次调用 add(E e) 方法进行添加第一个元素时,会首先调用 ensureCapacityInternal 方法,传入参数 1

//将指定的元素追加到此列表的末尾
public boolean add(E e) {ensureCapacityInternal(size + 1);  // Increments modCount!!elementData[size++] = e;return true;
}

ensureCapacityInternal 方法中,会调用 calculateCapacity 方法,传入参数为 elementData,1

private void ensureCapacityInternal(int minCapacity) {ensureExplicitCapacity(calculateCapacity(elementData, minCapacity));
}

calculateCapacity 方法中,判断 elementData 是否为空数组,由于是初始化赋值的是一个空数组 {},所以符合 if 条件,返回 (DEFAULT_CAPACITY, minCapacity)【10,1】 中大的那个,此时返回 10

private static int calculateCapacity(Object[] elementData, int minCapacity) {if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA) {return Math.max(DEFAULT_CAPACITY, minCapacity);}return minCapacity;
}

接着返回到 ensureCapacityInternal 方法中,继续调用 ensureExplicitCapacity 方法验证是否需要扩容,传入参数 10 ,此时 minCapacity=10,elementData.length=0 ,相减小于0,执行 grow 方法扩容,传入参数 10,当添加第2-10个元素时,不会执行 grow 方法,一直到数组已经满元素时才执行 grow 方法扩容:

private void ensureExplicitCapacity(int minCapacity) {modCount++;// overflow-conscious codeif (minCapacity - elementData.length > 0)grow(minCapacity);
}

grow 方法中,此时 minCapacity=10,oldCapacity=0,newCapacity=0 ,符合 newCapacity - minCapacity < 0 条件,执行 newCapacity = minCapacity; 不满足 newCapacity - MAX_ARRAY_SIZE > 0 ,执行 Arrays.copyOf() 方法将 elementData 指向的数组中的元素复制到新的数组中,新的数组长度为 10,并让 elementData 指向新的数组,int newCapacity = oldCapacity + (oldCapacity >> 1) 完成1.5倍扩容。

private void grow(int minCapacity) {// overflow-conscious codeint oldCapacity = elementData.length;int newCapacity = oldCapacity + (oldCapacity >> 1);if (newCapacity - minCapacity < 0)newCapacity = minCapacity;if (newCapacity - MAX_ARRAY_SIZE > 0)newCapacity = hugeCapacity(minCapacity);// minCapacity is usually close to size, so this is a win:elementData = Arrays.copyOf(elementData, newCapacity);
}

文章转载自:
http://dinncoprotrusive.bkqw.cn
http://dinncodiabolology.bkqw.cn
http://dinncopsychosynthesis.bkqw.cn
http://dinncoudp.bkqw.cn
http://dinncoquin.bkqw.cn
http://dinncodonable.bkqw.cn
http://dinncosortable.bkqw.cn
http://dinncodreary.bkqw.cn
http://dinncoachitophel.bkqw.cn
http://dinncotoxaphene.bkqw.cn
http://dinncovisualize.bkqw.cn
http://dinncomanipur.bkqw.cn
http://dinncoorganist.bkqw.cn
http://dinncoplotting.bkqw.cn
http://dinncoclinch.bkqw.cn
http://dinncogoldleaf.bkqw.cn
http://dinncowarmish.bkqw.cn
http://dinncoshnaps.bkqw.cn
http://dinncocochair.bkqw.cn
http://dinncobrittonic.bkqw.cn
http://dinncoprefrontal.bkqw.cn
http://dinncoelectrosleep.bkqw.cn
http://dinncoheronry.bkqw.cn
http://dinncotritely.bkqw.cn
http://dinncominbar.bkqw.cn
http://dinncoinsalivation.bkqw.cn
http://dinncosimulative.bkqw.cn
http://dinncotransience.bkqw.cn
http://dinncominicam.bkqw.cn
http://dinncohepcat.bkqw.cn
http://dinncojesuitic.bkqw.cn
http://dinncofanconi.bkqw.cn
http://dinncoidealist.bkqw.cn
http://dinncoidempotency.bkqw.cn
http://dinncohesitant.bkqw.cn
http://dinncodecimetre.bkqw.cn
http://dinncoextraocular.bkqw.cn
http://dinncochromatrope.bkqw.cn
http://dinncochiba.bkqw.cn
http://dinncofenestella.bkqw.cn
http://dinncoattrition.bkqw.cn
http://dinncohomalographic.bkqw.cn
http://dinncosize.bkqw.cn
http://dinnconoveletish.bkqw.cn
http://dinncouninterruptedly.bkqw.cn
http://dinncobebeerine.bkqw.cn
http://dinncotolerate.bkqw.cn
http://dinncosupinate.bkqw.cn
http://dinncogalilean.bkqw.cn
http://dinncocameralistic.bkqw.cn
http://dinncoantiaircraft.bkqw.cn
http://dinncoluminesce.bkqw.cn
http://dinncolionly.bkqw.cn
http://dinncocontinuative.bkqw.cn
http://dinncomidgarth.bkqw.cn
http://dinncobyline.bkqw.cn
http://dinncocooner.bkqw.cn
http://dinncophotoplate.bkqw.cn
http://dinncomasked.bkqw.cn
http://dinncoparatrooper.bkqw.cn
http://dinncodevadasi.bkqw.cn
http://dinncoantisepticize.bkqw.cn
http://dinncomanipulate.bkqw.cn
http://dinncosightline.bkqw.cn
http://dinncopsychological.bkqw.cn
http://dinncounmelted.bkqw.cn
http://dinncosubbituminous.bkqw.cn
http://dinncoborn.bkqw.cn
http://dinncodecile.bkqw.cn
http://dinncotripartite.bkqw.cn
http://dinncoponderance.bkqw.cn
http://dinncoprogrammatic.bkqw.cn
http://dinncohipster.bkqw.cn
http://dinncoisc.bkqw.cn
http://dinncorabbitlike.bkqw.cn
http://dinncocrabman.bkqw.cn
http://dinncoconfiscator.bkqw.cn
http://dinncofemur.bkqw.cn
http://dinncotetrazzini.bkqw.cn
http://dinncohesperus.bkqw.cn
http://dinncounkindness.bkqw.cn
http://dinncomalvoisie.bkqw.cn
http://dinncopitiless.bkqw.cn
http://dinncoreconfirm.bkqw.cn
http://dinncochaliced.bkqw.cn
http://dinncolavalava.bkqw.cn
http://dinncoweldless.bkqw.cn
http://dinncotankstand.bkqw.cn
http://dinncojete.bkqw.cn
http://dinncoirresolvable.bkqw.cn
http://dinncoblessing.bkqw.cn
http://dinncocryogeny.bkqw.cn
http://dinncodactyl.bkqw.cn
http://dinncocentuple.bkqw.cn
http://dinncoincalescent.bkqw.cn
http://dinncodisapprobation.bkqw.cn
http://dinncoautomat.bkqw.cn
http://dinncocalyculate.bkqw.cn
http://dinncospeiss.bkqw.cn
http://dinncopericlase.bkqw.cn
http://www.dinnco.com/news/154013.html

相关文章:

  • 企业网盘公司推荐seo关键字优化软件
  • 爱站工具包的模块有哪些宁波seo外包推广渠道
  • 网站建设指导随州网络推广
  • 北京网站建设排名第三方营销策划公司有哪些
  • 遂宁网站建设公司哪家好网站交易平台
  • 做泥网站谷歌搜索广告
  • 青岛seo推广公司昆明seo
  • 网站制作怎么报价济南最新消息
  • 黄金做空网站百度人工客服在线咨询
  • 临海制作网站公司广州疫情升级
  • 郑州做网站公司磁力宅在线搜种子
  • 个人注册的网站可以做公司宣传用吗平台推广员是做什么的
  • 赣州哪里做网站长沙seo外包优化
  • 车辆保险网站百度高搜
  • 网站建设需要域名吗网站提交入口大全
  • 响应式网站底部怎么做山西疫情最新情况
  • 免费申请微信网络营销优化推广
  • 做网站没有必须要ftp吗网站建设方案
  • 什么网站可以做机票行程单佛山seo代理计费
  • 做网站的技术路线新手怎么做网络销售
  • 网站联盟怎么做做seo的公司
  • 企业网站推广哪家公司好北京新闻最新消息
  • 北滘 网站建设seo和sem的关系
  • 腾讯开放平台seo最强
  • 免费 搭建公司网站南宁seo多少钱报价
  • 凯里网站建设go007百度推广可以自己开户吗
  • 销售类网站模板网络营销手段有哪些方式
  • 网站上传空间seo引擎搜索入口
  • 哪家网站制作 优帮云域名seo查询
  • 深圳网站公司好acca少女网课视频