I am working with vectors and when I copy the data and try to edit it the vector and the copy both change.
//The vectors contains int[] and the first 3 are loaded with int values.
int ToCheck[] = OpenSet.elementAt(Current);
ToCheck[1] = ToCheck[1] + 1; // This changes OpenSet and ToCheck[].
boolean IsInVector = false;
for(int y = 0;y < OpenSet.size(); y++){
if(ToCheck == OpenSet.elementAt(y)) // Because it changed both values it always is true
{
IsInVector == true;
}
}
I want to be able to copy the data in the vector and edit it without changing the original.
The simple way to copy an array is to use
Arrays.copyOf:And while you are listening, PLEASE learn to use the accepted Java naming conventions. Method names and field/parameter/local names should start with a lower-case letter.