The collection of java (List Set Map, etc.) features brief

Java collections of commonly used features outlined

1 Collection separate collection

List 1.1 (ordered repeatable)

ArrayList : the underlying array, fast queries, additions and deletions slow, thread-safe, efficient, index, repeatable

Vector : is the old version of the ArrayList, the only difference is that Vector is thread-safe

The LinkedList : bottom list (deque), query slow, fast deletions, features list includes

1.2 Set Interface (unordered unique)

HashSet : based on a hash table structure, the only disorder

. A storage disorder because hashCode hash value stored in the index table about the object, hashCode is relatively random, so the disorder;

. B unique, deduplication equals and hashCode method relies on;

c. You can store null, null but can not be repeated.

TreeSet : based on the binary tree structure, the only element, comparable sortable

. A de-duplication, relies on the storage characteristics of the binary tree;

. B taken depends on the characteristics of ordering binary tree;

C. natural ordering and sorting comparator.

LinkedHashSet : linked lists and hash tables, based on the only orderly

. A orderly list to ensure orderly;

b. The only hash table guaranteed to be unique.

Double row set 2 Map

HashMap 2.1 : disorderly, Unique, threads are not synchronized, non-security

LinkedHashMap 2.2 : orderly, threads are not synchronized, non-security

The HashTable 2.3 : disorderly, thread synchronization, security

TreeMap 2.4 : orderly, threads are not synchronized, non-security

Published 22 original articles · won praise 22 · views 771

Guess you like

Origin blog.csdn.net/weixin_45568892/article/details/105176762