Java Collection series

Source: Internet
Author: User

Since the work, has been the Java Collection understanding is not comprehensive enough, not deep enough, is commonly used arraylist/hashmap/set/list, sometimes will use a linkedlist. On a whim, there may be some interest in treeset,hashset. However, the collection of these companies interview often asked, especially the tall company also asked very deep. So I search for some information, according to their own understanding of the reorganization.

Java Collection frame diagram: http://www.cnblogs.com/lmy-foolishbird/p/5405641.html

Key points:

1. Top-level interface: Java.util.collection,java.util.iterator. (Java.lang.Iterable is not in java.util.) Classes that implement the Iterable interface can traverse the collection collection through iterator, but traverse the map)

2.Collection Next face interface determines whether internal elements are ordered or unordered:

List interfaces, lists, commonly used implementations have the array implementation of the ArrayList, linked list implementation of the LinkedList. All allow the addition of duplicate elements. Disordered

The set interface, set, does not allow repeating elements. Common implementation classes have HashSet (through the map of the HashMap implementation, unordered), TreeSet (through the TREEMAP implementation of the map, ordered also implemented SortedSet interface, so is ordered)

Deque interface, queue, bidirectional

The vector class is an array of vectors that can be used to grow an array of objects, usually implemented as stack stacks, advanced and out;

3. A design pattern is used in the Set frame: Adapter mode. Adapter Mode key points: If a ray, want to implement a partial method of an interface, not all, this time add an intermediate abstract class, this abstract class implements all the methods in the interface, and then our own front-line implementation class inherits this abstract class, implementation of the abstract class part of the method can be.

For example: Map interface, through Abstractmap abstraction, in to specific Treemap,hashmap implementation class.

The 4.Arrays and Collections tool classes are the two tool classes used to manipulate arrays and collections.

5. The source code behind the jdk1.8 is checked.

Java Collection series

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.