当前位置:网站首页>The difference between arrayslist and LinkedList
The difference between arrayslist and LinkedList
2022-07-18 14:51:00 【Shikb】
1、 Whether threads are safe
because ArrayList and LinkedLit It's all out of sync , That is, thread safety is not guaranteed
2、 Underlying data structure
ArrayList The underlying data structure of is Object Array to achieve ;LinkedList It is achieved by using linked lists (JDK1.6 It used to be a circular list ,JDK1.7 Then the cycle is cancelled ).
3、 Whether the deletion or insertion of data is affected by the location
ArrayList Because it is implemented by array , So when the position of insertion or deletion is not at the end of the array , Then his time complexity is O(1), When the position is i In position , Because when deleting, you need to move the following elements forward , When inserting , Just move the following elements back , So time complexity is O(n-i); and LinkedList The bottom layer of is implemented by using linked lists , When inserting or deleting elements at the beginning and end , Time complexity O(1), When it is necessary to insert the specified position , You need to move to the specified position first , Inserting or deleting , So the time complexity is O(n).
4、 Can I have random access
ArrayList It's an array implementation , So you can randomly access , Query through its array index ,LinkedList Random query is not supported
5、 Occupancy space
ArrayList Use arrays to implement , Finally, a space will be left , So it takes up more space ; and LinkedList Use the list , Will not appear in the back to leave room , But when storing each element , It will also store the front drive and rear drive keys , So it will be better than ArrayList Take up more space
边栏推荐
- Minimum interval problem
- Wwdc22 - Apple privacy technology exploration
- Thinkphp5.1.37 deserialization chain analysis
- Gee (6): set the number of decimal places reserved for the calculated value / image
- ViewGroup event distribution sorting
- 数百亿数据压缩至 600GB,TDengine 落地协鑫能科移动能源平台
- 03-GuliMall 开发环境配置
- Design of hydrogen monitoring and alarm system based on single chip microcomputer (0492)
- 启动失败 Failed to determine a suitable driver class 问题解决方案
- 通过装饰器获取调用函数的文件名称及函数名称
猜你喜欢

Fleet |「后台探秘」第4期:分布式事务

vivado里那些看不懂的约束语句

Conditional ternary operator...

Wechat selection and voting of applet completion works applet graduation project (8) graduation project thesis template

What if win11 prompts outlook for search errors? Win11 prompt outlook search error

Design of hydrogen monitoring system based on single chip microcomputer (0491)

One click VR panorama display

LeetCode(剑指 Offer)- 03. 数组中重复的数字

Antd a-upload limit the number of uploads when multiple is true

Wechat selection and voting of applet completion works applet graduation design (5) assignment
随机推荐
How to solve the problem of high concurrency? You will understand it completely after reading it.
Nc16857 [noi1999] birthday cake
Eureka read-write lock fantasy, too top!
Top k high frequency elements
Shell脚本中的变量
数据敏捷,HTAP数据库既决效率又决生死
Angr principle and Practice (I) -- principle
sudo 找不到命令 command not found 解决方案
Will the arrears of Alibaba cloud international ECS be automatically released?
Hal firmware library
Ziguang Tongchuang FPGA development jump pit Guide (V) -- DDR3 controller IP simulation
StoneDB 宣布开源,一体化实时 HTAP 架构为何是当前最优解
Reconstructing the geometric form of weight space with training set
Antd a-upload limit the number of uploads when multiple is true
保研机试备考十四:BFS
小程序毕设作品之微信评选投票小程序毕业设计(6)开题答辩PPT
学习路之PHP--post获取不到请求数据
Methods and extensions of array objects, extension methods of strings, and traversal of arrays in ES6
How to choose databases and tables and newsql?
分库分表和 NewSQL 到底怎么选?