Java Collection Framework

Source: Internet
Author: User

1.JAVA Set frame diagram

2. A general explanation of the architecture of the Java collection

list, set, and map are the three most important interfaces in this set system.

List and set inherit from collection interface

Set does not allow elements to be duplicated. HashSet and TreeSet are two main implementation classes

The list is ordered and allows elements to be duplicated. ArrayList, LinkedList, and vectors are the three main implementation classes.

The map also belongs to the collection system, but differs from the collection interface. A map is a collection of key pairs of value, where the key column is a collection. Key cannot be duplicated, but value can be repeated. HashMap, TreeMap, and Hashtable are the three main implementation classes.

3. What is the difference between ArrayList and vectors?

 ArrayList The Add method:
Public
BooleanAdd (e e) {ensurecapacityinternal (size+ 1); elementdata[size++] =e; return true;}
Vector's Add method:
Public synchronized BooleanAdd (e e) {Modcount++; Ensurecapacityhelper (Elementcount+ 1); Elementdata[elementcount++] =e; return true;}
Conclusion: Vectors are thread-synchronized (synchronized), ArrayList are non-synchronous
So on the performance: ArrayList is better than vector

Java Collection Framework

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.