Java-----------> Collection Classes

Source: Internet
Author: User
Tags set set

Java collection classes

  (i) Classification of collection classes: List, Set,queue (belongs to collection Interface), map (belongs to map interface)

      Framework structure of the collection interface:

      The frame structure of the map interface:

set Collection class:(Collections.synchronizedsortedset (new Setreet) is required to wrap the class in order to ensure multithreading security)

1,hashset Collection class: (Essence is the key value of HashMap, note its hashcode and Equals method, details can refer to:): Fast causes the stored value is calculated directly from the hash algorithm.

2,linkedhashset Collection Class: The order of storage is consistent with the order of addition, so in order to maintain the insertion of the list, its performance is reduced, it is better than hashset

3,treeset collection classes: Implemented by the SortedSet class, sorted in order, using sorting algorithm: Natural sort (red-black tree structure sort)

4,enumset Collection Class: Set for Enumeration (best in Set Set)

  2,list Collection Class

ArrayList differs from Vector: the former is thread insecure and requires code assurance while the latter is thread-safe, but is not recommended for use.

Likedlist: Implements the Deque interface, can be used as a queue, stack, double-ended queue to use

  3,queue Collection class:

1,piorityqueue: Not output in FIFO order, but as ascending of element, no NULL allowed

2,deque: Double-ended queue, using Arraydeque as a queue or as a stack operation (push into the stack, pop out of the stack)

 4.Map Collection class:

The difference between 1,hashmap and Hashtable

2,linkedhashmap: two-terminal queue implementation

3,weakhashmap: For weak references, that is, the key value is anonymous and the wrapper reference is a weak reference.

4,identityhashmap: The insertion is not allowed only if the a==b is strictly equal, and HashMap is a.equals (b);

5,enummap:key must be an enumeration type (best performance in map)

  (ii), the tool class that operates the collection------collections

    1, Sort operations:

    2, find, replace, etc. operation:

    3, synchronous control operation:

Collections.synchronizedset ()----------collections.synchronizedlist ()---------------- Collections.synchronizedmap ()

Java-----------> Collection Classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.