Java Surface Question-java container

Source: Internet
Author: User

First, Java container classification

The Java container is divided into two concepts collection, MAP

Collection:

A sequence of independent elements that obey one or more rules. List must save elements in the order in which they are inserted, do not care whether they are duplicated, set cannot have duplicate elements, and one end of the queue inserts an output. All collection can be traversed with the foreach syntax

Realization: List:arraylist, LinkedList;

Set: HashSet, TreeSet, Linkedhashset

Map:hashmap, TreeMap, Linkedhashmap

MAP: "Key-value pairs object", which allows you to use keys to find values.

Simple Container classification:

  

Second, the related class introduction
Arrays and Collections classes in the Java.util package: Arrays.aslist (); // accept an array or a comma-delimited list of elements to convert to list.  New arraylist<integer> (Arrays.aslist (1,2,3,4,5))

Collections.addall (); //Accept an collection object, and an array or a comma-delimited list of elements to add to the collection.
Collections.addall (collection,11,12,13,14);

The Retainall () method in the list is the intersection operation.
Copy.retainall (sub); //Ask for the intersection of Copy list and sub list and update copy list.

LinkedList
LinkedList adds a method that can make it work on a stack queue or a double-ended queue. It implements the queue interface, which can be implemented as a queue.
queue<integer> queue = new linkedlist<integer> ();
Offer ();//Insert to the end of the team
Peek () and element ();//Return to team header without removing
Poll (); remove ();

Third, attention

The collection class holds all references to objects, not the objects themselves

Java Surface Question-java container

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.