import java.util.*;
public class MyClass {
public static void main(String args[]) {
List<List<Integer>> l = new ArrayList<List<Integer>>();
List<Integer> a = new ArrayList<Integer>();
a.add(1);
a.add(2);
l.add(a);
a.clear();
a.add(4);
a.add(5);
l.add(a);
System.out.println(l+" | ");
}
}
output - [[4, 5], [4, 5]] |
I want it to display - [[1,2],[4,5]]
What is wrong with my code?