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