List is a subinterface of Collection, so it cannot be instantiated. It can be instantiated through its subset, which can be repeated and stored in the same order as retrieved

The subclasses of List are ArrayList, Vector, LinkedList

ArrayList: The underlying data structure is an array, fast query, slow add and delete, thread insecurity, high efficiency. Vector: The underlying data structure is an array. It is fast to query, slow to add and delete, and is thread-safe and inefficient. LinkedList: the underlying data structure is a LinkedList, which is slow to query, fast to add and delete, unsafe threads, and efficient.

Here is the List definition and traversal:

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		
		list.add("hello");
		list.add("world");
		list.add("java");
		
		// set traversal
		Iterator<String> it = list.iterator();// Iterator iterates through the collection
		while(it.hasNext()) {
			System.out.println(it.next());
		}
		
		for(String s : list) { System.out.println(s); }}}Copy the code

ArrayList is similar to List:

import java.util.ArrayList;
import java.util.Iterator;

public class Main {
	public static void main(String[] args) {
		ArrayList<String> list = new ArrayList<String>();
		
		list.add("hello");
		list.add("world");
		list.add("java");
		
		// set traversal
		Iterator<String> it = list.iterator();// Iterator iterates through the collection
		while(it.hasNext()) {
			System.out.println(it.next());
		}
		
		for(String s : list) { System.out.println(s); }}}Copy the code

Running results: