I have two values, small_red
and small_blue
:
private EnemyInfo small_red = new EnemyInfo("Red Fighter", Core.jf.getToolkit().createImage(Core.class.getResource("/com/resources/ENEMY_01.png")), 10, 100, new Location(0, 0), false, 0);
private EnemyInfo small_blue = new EnemyInfo("Blue Fighter", Core.jf.getToolkit().createImage(Core.class.getResource("/com/resources/ENEMY_02.png")), 50, 100, new Location(0, 0), false, 0);
and an ArrayList:
private ArrayList<EnemyInfo> activeEnemies = new ArrayList<EnemyInfo>();
Let's say I add three of the small_red
and five of the small_blue
enemies into the activeEnemies
. Whenever I want to change a variable inside the array, e.g.:
activeEnemies.get(1).setActive(true); // change one of the small_red enemies
every small_red
in the array is changed, instead of just the one at index 1
.