I found a very weird issue in my code , when I have a list called "pathToBank" and I let it = pathToAltar , then I do Collections.reverse(pathToBank) it changes both pathToAltar and pathToBank to the reversed version of pathToAltar , does this have to do with Java refrencing? did I mess something up? to my knowledge , it shouldn't affect pathToAltar at all
switch(modeName[index]) {
case("Air"):{
bankArea = new Area(3008, 3359, 3022, 3352);
altarArea = new Area(2980, 3295, 2991, 3283);
//rcArea =
pathToAltar = new ArrayList<Position>();
pathToAltar.add(new Position(3013, 3356, 0));
pathToAltar.add(new Position(3010, 3360, 0));
pathToAltar.add(new Position(3006, 3360, 0));
pathToAltar.add(new Position(3005, 3356, 0));
pathToAltar.add(new Position(3006, 3348, 0));
pathToAltar.add(new Position(3006, 3339, 0));
pathToAltar.add(new Position(3005, 3326, 0));
pathToAltar.add(new Position(3006, 3314, 0));
pathToAltar.add(new Position(3006, 3308, 0));
pathToAltar.add(new Position(3004, 3302, 0));
pathToAltar.add(new Position(3002, 3298, 0));
pathToAltar.add(new Position(2995, 3295, 0));
pathToAltar.add(new Position(2989, 3292, 0));
pathToBank = pathToAltar;
Collections.reverse(pathToBank); //this messes up both variables not only pathToBank
break;
}
}
I think what I'm lacking is maybe initialize pathToBank as a new ArrayList<Position> instead of making it just a reference pointer?