I am attempting to add arraylists to the arraylist of arraylists I believe(sorry I'm a beginner), but whenever I void the temporary so I can grab the next line of data to be added, it changes the main arraylist as well. Is there any way to copy only the values without making it point to the same reference?
for (int n=0; n!=cellCount+1; n++)
{
temp.add(inputFile.nextDouble());
System.out.println(temp);
}
mainList.add(temp);
//}
temp.clear();
System.out.println(mainList);
prints: [0.0, 4.0, 6.0, 9.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0]As the final temp arraylist before it is cleared
[[]]As the mainList