Two main interfaces: collection and map
Three main categories: collection (set), list, mapping (map)
1. Collection: No duplicate objects, no specific sort method
2. List: objects are sorted by index location and can have duplicate objects
3. Mapping: There is a key object and a value object, the key is not repeatable, the value can be repeated
Here we introduce list
List is the interface, linklist and ArrayList are the implementation classes of the list
Linklist is implemented with a linked list, and ArrayList is implemented using arrays.
ArrayList: Cons: Memory usage is larger, adding delete elements is less efficient. Element random access is highly efficient.
LinkedList: On the contrary.
Import Java.util.arraylist;public class Main {public static void main (String args []) {//list definition arraylist<string> ar Y=new arraylist<string> ();//list add element Ary.add ("AB"), Ary.add ("CD"), Ary.add ("EF");//Get element value String s=ary.get (1); /arraylist from 0 bits, and arrays as System.out.println (s);//delete element value Ary.remove (0);//Remove the preceding element, followed by automatic forward fill//returns the number of elements in the current list ary.size ();}}
Java class set framework