侧边栏壁纸
博主头像
王小木人

这是很长,很好的一生

  • 累计撰写 141 篇文章
  • 累计创建 43 个标签
  • 累计收到 7 条评论

目 录CONTENT

文章目录

java 中collection ,List, ArrayList,LinkedList,Vector之间的关系和区别

王小木人
2021-05-22 / 0 评论 / 0 点赞 / 1,077 阅读 / 3,403 字

Collection:集合接口,List, ArrayList,LinedList,Vector均是其子类实现

以下为Java10文档的描述

Module java.base

Package java.util

Interface Collection
Type Parameters:

E - the type of elements in this collection

All Superinterfaces:

Iterable

All Known Subinterfaces:

BeanContext, BeanContextServices, BlockingDeque, BlockingQueue, Deque, EventSet, List, NavigableSet, ObservableList, ObservableListValue, ObservableSet, ObservableSetValue, Queue, Set, SortedSet, TransferQueue, WritableListValue, WritableSetValue

All Known Implementing Classes:

AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet, ArrayBlockingQueue, ArrayDeque, ArrayList, AttributeList, BeanContextServicesSupport, BeanContextSupport, ConcurrentHashMap.KeySetView, ConcurrentLinkedDeque, ConcurrentLinkedQueue, ConcurrentSkipListSet, CopyOnWriteArrayList, CopyOnWriteArraySet, DelayQueue, EnumSet, FilteredList, HashSet, JobStateReasons, LinkedBlockingDeque, LinkedBlockingQueue, LinkedHashSet, LinkedList, LinkedTransferQueue, ListBinding, ListExpression, ListProperty, ListPropertyBase, ModifiableObservableListBase, ObservableListBase, PriorityBlockingQueue, PriorityQueue, ReadOnlyListProperty, ReadOnlyListPropertyBase, ReadOnlyListWrapper, ReadOnlySetProperty, ReadOnlySetPropertyBase, ReadOnlySetWrapper, RoleList, RoleUnresolvedList, SetBinding, SetExpression, SetProperty, SetPropertyBase, SimpleListProperty, SimpleSetProperty, SortedList, Stack, SynchronousQueue, TransformationList, TreeSet, Vector

public interface Collection
extends Iterable

List:集合接口,是collection的子接口, ArrayList,LinedList,Vector是其实现的类,

Module java.base

Package java.util

Interface List
Type Parameters:

E - the type of elements in this list

All Superinterfaces:

Collection, Iterable

All Known Subinterfaces:

ObservableList, ObservableListValue, WritableListValue

All Known Implementing Classes:

AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, FilteredList, LinkedList, ListBinding, ListExpression, ListProperty, ListPropertyBase, ModifiableObservableListBase, ObservableListBase, ReadOnlyListProperty, ReadOnlyListPropertyBase, ReadOnlyListWrapper, RoleList, RoleUnresolvedList, SimpleListProperty, SortedList, Stack, TransformationList, Vector

public interface List
extends Collection
ArrayList:数组集合类,其实现由数组完成,初始化无参实例,默认长度为10,当增加元素超过长度时以2倍长度来增加,10,20,40,80....线程不安全。
Module java.base

Package java.util

Class ArrayList
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.ArrayList
Type Parameters:

E - the type of elements in this list

All Implemented Interfaces:

Serializable, Cloneable, Iterable, Collection, List, RandomAccess

Direct Known Subclasses:

AttributeList, RoleList, RoleUnresolvedList

public class ArrayList
extends AbstractList
implements List, RandomAccess, Cloneable, Serializable
LinkedList:链表集合类,由链表实现,初始化无参实例时没有大小,

Module java.base

Package java.util

Class LinkedList
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.AbstractSequentialList
java.util.LinkedList
Type Parameters:

E - the type of elements held in this collection

All Implemented Interfaces:

Serializable, Cloneable, Iterable, Collection, Deque, List, Queue

public class LinkedList
extends AbstractSequentialList
implements List, Deque, Cloneable, Serializable
Vector:数组集合类,和ArrayList类似,但是其相关方法实现由synchronized修饰,所以是线程安全的,效率相对低

0

评论区