jianglilili / jianglilili/guodegang.github.io

List接口及其主要实现类

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### [List接口及其主要实现类](https://blog.csdn.net/SongBai1997/article/details/83042238)
List接口继承和扩展了Collection接口,List接口表示具有顺序的集合,其中可以包含重复元素。使用此接口的实现类时,可以对列表中每个元素的插入位置进行精确的控制,用户可以根据元素的整数索引(在列表中的位置)访问元素,并搜索列表中的元素。
**List接口的实现类主要有ArrayList、Stack、Vector和LinkedList**

### 对比LinkedList和ArrayList之间的区别

1. 两者都是允许重复元素,允许null元素,且空间会自动增长的列表集合

2. LinkedList是以_链表形式_实现的List集合,ArrayList是以_数组的形式_实现的List集合

3. **存储元素**时,若是存尾部位置,那么两者效率是一致的;若是存储在其他位置,则ArrayList会涉及到数组的复制(也就是常说的位置偏移),而LinkedList只是简单的循环索引添加节点元素,因此LinkedList效率会高于ArrayList

4. **查看元素**时,若是获取头尾元素位置,那么两者效率一致;若是获取其他位置,ArratyList可以通过索引直接获取到元素,而LinkedList需要进行循环索引(从前或者从后),因此ArrayList效率要高于LinkedList

5. **删除元素**时,若是删除尾部元素,则两者效率一致;若是删除其他位置,则ArrayList涉及到数组复制,而LinkedList只是简单循环索引,因此LinkedList效率高于ArrayList

6. **修改元素**时,ArrayList可以根据指定位置进行元素的替换,LinkedList需要循环索引,因此ArrayList效率要高于LinkedList

7. _因此在使用这两个列表集合进行元素操作时,需要考虑使用情况,若只是存储元素用于循环查看,那么建议使用ArrayList;若是涉及较多的插入和删除等,则建议使用LinkedList_

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue contains a Chinese article about Java's List interface and compares ArrayList with LinkedList, but names no repository file, test, or entry point. First inspect the repository structure to determine where this content belongs and clarify the intended documentation change; done should be a clearly scoped update in the appropriate location.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.