Collection of the frame structure brief

Collection: List List, Set collection

Map:Hashtable,HashMap,TreeMap

 

Collection is a collection of separate

List elements are ordered, repeatable

Ordered collection, can be accurately controlled to the insertion position of each list element.

Access to elements based integer index (position in the list), and search for elements in the list. 

Repeating elements can be stored, the access element is ordered.

List class interface used

l Vector: thread-safe, but slow, it has been replaced by ArrayList.

Underlying data structure is an array of structure

l ArrayList: thread-safe, fast query speed.

            Underlying data structure is an array of structure

l LinkedList: thread safe. Additions and deletions fast speed.

             The underlying data structure is a list structure

 

Set (set) element disordered unrepeatable.

The method of extraction elements only iterator. Not repeated storage elements, unordered element is accessed.

Set interface commonly used in class

l HashSet: thread-safe, fast access speed.

          How it is to ensure the uniqueness of the elements? HashCode method relies euqals elements and methods.

l TreeSet: thread-safe, can sort Set elements in the collection.

          It is sort of how it? Or by compareTo compare methods to ensure the uniqueness of the element. Element in the form of a binary tree stored.

 

 

Map is a two-column set

| --Hashtable: thread-safe, fast. The bottom layer is a hash table data structure. It is synchronized.

As a key does not allow null, null as a value.

      | --Properties: operational profile for defining and using a very high frequency, while the keys and values ​​are strings.

It is a collection of objects and can be combined IO technology. (To the IO in learning its unique and io related functions.)

| --HashMap: thread-safe, slow. The underlying data structure is a hash table. It is not synchronized.

As the key to allow null, as null values. It replaces Hashtable.

      | --LinkedHashMap: HashMap can guarantee an ordered set. Deposit order consistent with the order and withdrawn.

| --TreeMap: Map can be used to set the sort key.

 

 

Collection and Collections of the difference between
 
Collection is a superior interface, a sub-set of interfaces and classes are mainly Set List, Map. 

Collections are for a collection class helper class provides a method of operating a set of tools: a series of static methods to achieve search, sort, and so thread-safe operations of the various collections.
Original: https: //blog.csdn.net/coodlong/article/details/50835440 

Guess you like

Origin www.cnblogs.com/xhlwjy/p/11269118.html