1ArrayList<String> list = new ArrayList<String>() {{
2 add("A");
3 add("B");
4 add("C");
5}};
6
1ArrayList<Type> obj = new ArrayList<Type>(
2 Arrays.asList(Object o1, Object o2, Object o3, ....so on));
1import java.util.*;
2public class InitializationExample1 {
3 public static void main(String args[]) {
4 ArrayList<String> obj = new ArrayList<String>(
5 Arrays.asList("Pratap", "Peter", "Harsh"));
6 System.out.println("Elements are:"+obj);
7 }
8}
1ArrayList<Type> list = new ArrayList<Type>(Arrays.asList(
2 elem1, elem2,..., elemN
3 ));