As Grodriguez says, Integer objects are immutable. The problem here is that you are trying to increase the int value of the player identifier, not the identifier itself. In Java 5+, you can simply write playerID++ .
As a side note, never call the Integer constructor. Take advantage of autoboxing by simply setting int to Integer directly, e.g. Integer foo = 5 . This will use the transparent Integer.valueOf(int) , which is superior to the constructor because it does not always have to create a new object.
ColinD Sep 28 '10 at 17:06 2010-09-28 17:06
source share