Java Collection Learning (i) overall framework

Source: Internet
Author: User
Tags abstract arrays data structures set set

Java collection is a Java-provided toolkit that contains commonly used data structures: collections, lists, queues, stacks, arrays, mappings, and so on. Java Collection Toolkit location is java.util.*
Java collections can be divided into 4 main parts: List List, set set, map Map, tool class (iterator iterator, enumeration enum class, arrays and collections),.
Java Collection Toolkit framework diagram (as follows):

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/

General Description:

Looking at the frame above, first grab its trunk, collection and map.

The 1 collection is an interface, a highly abstracted set that contains the basic operations and attributes of the collection.

collection contains both the list and set branches.
The list is an ordered queue, and each element has its index. The index value of the first element is 0.
The implementation class of list has LinkedList, ArrayList, Vector, Stack.

Set is a collection that does not allow duplicate elements.
The implementation class for set has Hastset and TreeSet. HashSet relies on HashMap, which is actually implemented through HASHMAP, and TreeSet relies on treemap, which is actually implemented through TREEMAP.

The 2 map is a mapping interface, that is, a Key-value key value pair. Each element in the map contains "one key" and "key corresponding value".

Abstractmap is an abstract class that implements most of the APIs in the map interface. And Hashmap,treemap,weakhashmap are inherited from Abstractmap.
Although Hashtable inherits from the dictionary interface, it implements the map interface.

Next, look at the iterator. It is the tool that traverses the collection, that is, we usually traverse the collection through the iterator iterator. We say that collection relies on iterator because the collection implementation class implements the iterator () function and returns a iterator object.
The Listiterator is specifically designed to traverse the list.

Looking at enumeration, it is an abstract class introduced by JDK 1.0. function is the same as iterator, but the enumeration function is less than iterator. In the above block diagram, enumeration can only be used in Hashtable, vectors, and stack.

Finally, look at arrays and collections. They are two tool classes that manipulate arrays and collections.

With the overall framework above, we then analyze each class separately.

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.