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

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:

    BeanContextBeanContextServicesBlockingDequeBlockingQueueDequeEventSetListNavigableSetObservableListObservableListValueObservableSetObservableSetValueQueueSetSortedSetTransferQueueWritableListValueWritableSetValue

    All Known Implementing Classes:

    AbstractCollectionAbstractListAbstractQueueAbstractSequentialListAbstractSetArrayBlockingQueueArrayDequeArrayListAttributeListBeanContextServicesSupportBeanContextSupportConcurrentHashMap.KeySetViewConcurrentLinkedDequeConcurrentLinkedQueueConcurrentSkipListSetCopyOnWriteArrayListCopyOnWriteArraySetDelayQueueEnumSetFilteredListHashSetJobStateReasonsLinkedBlockingDequeLinkedBlockingQueueLinkedHashSetLinkedListLinkedTransferQueueListBindingListExpressionListPropertyListPropertyBaseModifiableObservableListBaseObservableListBasePriorityBlockingQueuePriorityQueueReadOnlyListPropertyReadOnlyListPropertyBaseReadOnlyListWrapperReadOnlySetPropertyReadOnlySetPropertyBaseReadOnlySetWrapperRoleListRoleUnresolvedListSetBindingSetExpressionSetPropertySetPropertyBaseSimpleListPropertySimpleSetPropertySortedListStackSynchronousQueueTransformationListTreeSetVector


    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:

    CollectionIterable

    All Known Subinterfaces:

    ObservableListObservableListValueWritableListValue

    All Known Implementing Classes:

    AbstractListAbstractSequentialListArrayListAttributeListCopyOnWriteArrayListFilteredListLinkedListListBindingListExpressionListPropertyListPropertyBaseModifiableObservableListBaseObservableListBaseReadOnlyListPropertyReadOnlyListPropertyBaseReadOnlyListWrapperRoleListRoleUnresolvedListSimpleListPropertySortedListStackTransformationListVector


    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:

    SerializableCloneableIterableCollectionListRandomAccess

    Direct Known Subclasses:

    AttributeListRoleListRoleUnresolvedList


    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:

    SerializableCloneableIterableCollectionDequeListQueue


    public class LinkedList
    extends AbstractSequentialList
    implements List, Deque, Cloneable, Serializable

Vector:数组集合类,和ArrayList类似,但是其相关方法实现由synchronized修饰,所以是线程安全的,效率相对低

你可能感兴趣的:(java)