1ArrayList<Integer> str=new ArrayList<Integer>();
2str.add(0);
3str.add(1);
4 // Result = [0, 1]
5
6str.add(1, 11);
7 // Result = [0, 11, 1]
1ArrayList<String> arrayList = new ArrayList<>();
2// Adds element at the back of the list
3arrayList.add("foo");
4arrayList.add("bar");
5// Result = ["foo", "bar"]
6
7// Adds element at the specified index
8arrayList.add(1, "baz");
9// Result = ["foo", "baz", "bar"]