Why doesn’t this work?
private List<Integer> xShot = new ArrayList<Integer>();
...codes
...codes
...codes
...codes
xShot.get(0) += 5;
Can’t understand why the left-hand side of an assignment´isn’t is a variable..
Someone help?
If you just want to increment by 5 and aren’t limited to
List<Integer>specifically, you could avoid arguably verbosexShot.set(0, xShot.get(0) + 5)and do this instead:This will increment the value of the
AtomicIntegerinxShot.get(0)by 5 in-place without further ado.