There are three types of Java collections: List,set,map. List and set inherit the collection interface. Difference (list can add duplicate objects and sort by index position; Set does not have these two characteristics ).
Map is the value inside the key operation, which is the paired object. Put into the object, get to remove the object.
In addition: Colletion does not have random access to the Get () method because collection also includes set, and set has its own internal order. therefore, to examine the collection element, you must use the iterator object.
1, List has ArrayList (like array form for storage) and LinkedList (linked list form)
2, set specific implementation has hashset, TreeSet and Linkedhashset
1 ImportJava.util.*;2 3 Public classBasic {4 Public Static voidMain (string[] args) {5Collection<string> Collection =NewHashset<string> ();//hashset up, and use generics6Collection.add ("AAA");7Collection.add ("BBB");8Collection.add ("CCC");9Collections.addall (Collection, "E", "FFFF", "AAA");//using the AddAll method of the collection in the Java.util package, it is possible toTen //add data, but using Collection.add to do so will cause an error. OneIterator<string> it = Collection.iterator ();//using the iterator method, the method returns a iterator that moves between the elements of the container. A while(It.hasnext ()) - { -System.out.print (It.next () + ""); the } -System.out.print ("\ n" +collection); - } -}
Java Primary Knowledge collection (List,set,map)