Read [Main implementation class of collection interface and map interface] Summary

Source: Internet
Author: User

Collection interface

List interface

LinkedList [asynchronous] linked list storage, introduction data slow insertion data Fast implementation synchronization: List List = Collections.synchronizedlist (new LinkedList (...));

ArrayList [asynchronous] similar to array storage, continuous storage, the introduction of data fast insertion of data slowly before inserting the Ensurecapacity method can be invoked to increase the ArrayList capacity to improve the insertion efficiency.

vector[Sync] similar to ArrayList

Stack inherits vector five unique methods: Push pop peak empty search

Set interface (object cannot be duplicated)

HashSet can quickly locate elements by hashcode find elements, ensuring a.equals (B) while A.hashcode () ==b.hashcode ()

TreeSet are stored sequentially and need to implement comparator interfaces


Map interface

TreeMap Keys Store Unique methods sequentially: Getfirstkey () Getlastkey ()

HashTable [Synchronous]key and value are NOT NULL to ensure a.equals (B) while A.hashcode () ==b.hashcode () by hashing function positioning

HashMap [async] allows NULL to create a synchronized map through Collections.synchronizedmap ()

Weakhashmap improved HashMap, weak references, when a key is no longer externally referenced will be collected by GC


Related Article

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.