How do I increment a Integer\'s value in Java? I know I can get the value with intValue, and I can set it with new Integer(int i).
playerID.intValue()++;
All the primitive wrapper objects are immutable.
I'm maybe late to the question but I want to add and clarify that when you do playerID++, what really happens is something like this:
playerID = Integer.valueOf( playerID.intValue() + 1);
Integer.valueOf(int) will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range.