I have two ArrayLists (a1 and a2) as below:
ArrayList a1 = new ArrayList();
a1.add(8);
a1.add("a1");
ArrayList a2 = new ArrayList();
a2.add(a1); //output : [[8, a1]]
a2.addAll(a1); //output : [[8, a1], 8, a1]
My Questions:
- Why does
a2.addAll()method prints the data twice? - What is the exact difference between
addandaddAll? Both the methods return boolean.