Az nem egy _szám_, hanem egy objektum. Így:
public class Number {
private int value;
public Number(int initValue) {
value = initValue;
}
public void add(int otherValue) {
value = value + otherValue;
}
}
Ez az általános használata az OOP-nek és az egységbezárt (encapsulation) állapot kezelésnek.