List - java code code example
Example 1: list in java
LIST: Can store duplicate values,
Keeps the insertion order.
It allows multiple null values,
Also we can read a certain value by index.
- ArrayList not syncronized, array based class
- LinkedList not synchronized, doubly linked
- Vector is synchronized, thread safe
Example 2: declaration of list in java
ArrayList<String> list=new ArrayList<String>();
list.add("Mango");
list.add("Apple");
list.add("Banana");
list.add("Grapes");
System.out.println(list);