Arraylist
The underlying implementation is an array, query blocks, additions and deletions are slow. Thread is unsafe, but high efficiency
Vector
The underlying implementation is an array, query blocks, additions and deletions are slow. Thread-safe, low-efficiency.
LinkedList
The underlying implementation is linked list, query slow, adding and deleting blocks, thread insecure, high efficiency
Arraylist
Case one: simple storage and traversal, storing strings
ArrayList array=new ArrayList () array.add ("Hello"); Array.add ("Csz"); Array.add ("LC"); Iterator it=array.iterator (); while (It.hasnext ()) {string s= (String) it.next (); System.out.println (s);}
Case two: Storing custom objects Student
ArrayList array=new ArrayList (); Student s1=new Student (2, "carp"); Student s2=new Student (21, "Chen Shuze"); Student s3=new Student (23, "Zhang Tingting"); Student s4=new Student (26, "John Doe"); Array.add (S1); Array.add (S2); Array.add (S3); Array.add (S4); Iterator it= Array.iterator (); while (It.hasnext ()) {Student s= (Student) it.next (); System.out.println (s);} for (int i=0;i<array.size (); i++) {Student s= (Student) array.get (i); System.out.println (s);}
ArrayList of three kinds of lists