+ 1
Can we nest arraylist?
Can we nest arraylist? if yes can any one give me an example of it?
1 Answer
+ 5
ArrayList<ArrayList<String>> all = new ArrayList<>();
ArrayList<String> al = new ArrayList<>();
al.add("a");
all.add(al);
ArrayList<String> al2 = new ArrayList<>();
al2.add("b1");
al2.add("b2");
all.add(al2);
System.out.println(all);