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()++;
does not seem to work.
Note: PlayerID is a Integer that has been created with:
Integer playerID = new Integer(1);
Integerobjects are immutable, so you cannot modify the value once they have been created. You will need to create a newIntegerand replace the existing one.