Having problems clearing an arrayList
I m having a 2d arraylist and inside a loop i want to parse every 1d list of the 2d list to a temporary list. Also I want at the end of every iteration i want to clear this temporary list so to the next step to parse the i-est list of my initial 2d.
The code its the following:
Code:
List<List<Integer>> conVert = new ArrayList<List<Integer>>();
List<Integer> temp = new ArrayList<Integer>();
for (int i = 0; i<conVert.size(); i++){
temp.addAll(conVert.get(i));
Collections.sort(temp);
System.out.println(temp);
for(int j = 0; j<temp.size(); j++){
... several commands
}
temp.clear();
}
I have several commands which is not function well due to that temp doesnt clear properly. Any idea?