当前位置:网站首页>一个List到底能存多大的数据呢?
一个List到底能存多大的数据呢?
2022-07-26 00:09:00 【qq_25073223】
转自:
list简介:
继承于Collection接口,并且扩展出了自己的方法,是有序集合;
List集合中的元素都是与索引有关系的,因此List集合扩展的方法都是与索引有关系的。
例:add(int index, E) 添加元素在所对应的索引位置。
特点:存储有序的、不唯一的数据
1)数组存储的缺点:
长度开始必须执行,而且一旦指定,无法修改
保存的必须为同一类型的元素
使用数组进行增加/删除操作比较麻烦
(2)集合的优点:
可以动态保存多个对象,使用方便
提供了一系列方便的操作对象的方法,如add、remove、set、get等
使用集合增加/删除较方便
list集合的实现类:
ArrayList、Vector、LinkedList
ArrayList集合
最常见的一种集合。内部封装了一个数组对象和数组扩容的方法。可以将ArrayList看作是一个可变长度的数组。
注意事项:
- 一个ArrayList对象的初始容量为10,如果要存入大量数据,可以在创建对象时指定数组长度。
Vector集合
内部原理同ArrayList基本一致。可以看作是线程安全的ArrayList集合。
注意事项:
- 与ArrayList不同的是,Vector可以指定每次数组扩容的增加容量,通过两参构造方法依次传入长度、增加容量即可。
- 如果不指定增加容量或指定增加容量不大于0,那么默认指定增加长度为原来的数组长度。
LinkedList集合
内部封装了一个双向循环链表,内存中不连续存储。
LinkedList常用方法
| 方法 | 描述 |
|---|---|
| void add(int index,E element) | 在此列表指定位置插入指定元素 |
| void addFirst(Object o) | 将指定元素插入此列表的开头 |
| void addLast(Object o) | 将指定元素添加到此列表的结尾 |
| Object getFirst() | 返回此列表的第一个元素 |
| Object getLast() | 返回此列表的最后一个元素 |
| Object removeFirst() | 移除并返回此列表的第一个元素 |
| Object removeLast() | 移除并返回此列表的最后一个元素 |
那么一个List到底最大能存储多少数据呢?
下文笔者讲述java中List存储最大数据的简介说明,如下所示:
List是一个接口,那么List能存储多大的数据,由其实现类决定
如:
ArrayList最多能容纳的数据为 Integer.MAX_VALUE个元素 LinkedList理论上可以保存任意数量的元素,它的大小则由JVM的内存大小决定边栏推荐
- VMware ESXI7.0版本的安装与配置
- How long can this bull market last Answers to questions 2021-05-11
- BGR and RGB convert each other
- Under inflation, how to operate in the future? 2021-05-14
- Pytoch learning record (I): introduction to pytoch
- FreeRTOS personal notes - message queue
- STM32 lighting procedure
- Unified handling of global exceptions
- FreeRTOS个人笔记-互斥量
- Responsibility chain model of behavioral model
猜你喜欢

07_ue4进阶_发射火球扣mp值和攻击扣血机制

Unity -- Euler angle, quaternion

Redirection and request forwarding

Binary tree -- 222. Number of nodes of a complete binary tree

Binary tree - 226. Flip binary tree

最近随感,关于牛市和DeFi 2021-05-17
![[one library] mapbox GL! A map engine out of the box](/img/50/70e4679e74b2a53a3011e5a8e847da.jpg)
[one library] mapbox GL! A map engine out of the box

Solve the problem of rapid index bar extrusion

Detailed explanation of kubernetes network plug-ins - calico chapter - Overview

VMware ESXI7.0版本的安装与配置
随机推荐
What does it mean that the web server stops responding?
Module II operation
NVIDIA programmable reasoning accelerator tensorrt learning notes (III) -- Accelerating reasoning
What are the precautions for using MySQL index? (answer from six aspects)
Unity -- Euler angle, quaternion
Responsibility chain model of behavioral model
Solve the problem of rapid index bar extrusion
Cherish time and improve efficiency
Stm32- analyze latency based on assembly
SSM environment integration
[one library] mapbox GL! A map engine out of the box
"Animal coin" is fierce, trap or opportunity? 2021-05-12
Get JD product details original data API
Yolov4 tiny network structure
获得JD商品详情原数据 API
Under inflation, how to operate in the future? 2021-05-14
[英雄星球七月集训LeetCode解题日报] 第25日 树状数组
“群魔乱舞”,牛市是不是结束了?2021-05-13
bond网卡模式配置
34 use of sparksql custom functions, architecture and calculation process of sparkstreaming, dstream conversion operation, and processing of sparkstreaming docking Kafka and offset