I ve stuck with the following prob. Ignore the most code, my issue is: I have a different list x every iteration and I want to parse it in the 2DarrayList conVert so I use the conVert.add(x); but my problem is on x.clear();. When I print conVert before clear conVert is ok but when i print it after clear besides x also and conVert is cleared. What can I do for this? Thanks in advance
List<Integer> x = new ArrayList<Integer>();
// List<Integer> x1 = new ArrayList<Integer>();
List<Integer> valenceList = new ArrayList<Integer>();
List<List<Integer>> conVert = new ArrayList<List<Integer>>();
for (int q = 1; q <= 4; q++) {
for (int i = 0; i < Faces.length; i++) {
for (int j = 0; j < 2; j++) {
if (Faces[i][j] == q) {
x.add(Faces[i][0]);
x.add(Faces[i][1]);
x.add(Faces[i][2]);
}
}
}
removeDuplicateWithOrder((ArrayList) x);
valenceList.add(x.size() -1);
//x1 = x;
conVert.add(x);
System.out.println(conVert);
x.clear();
//System.out.println(conVert);
}