java - How to increment an integer by reference? -


Is it possible to increase the value from a integer value?

  int counter A = 0; Int counterB = 0; Int counter = (condition)? Counter A: Counter B; // counter counter ++;  

Result: Both Counter A + Counter B = 0, will be enlarged instead.

int is a primitive type, therefore no reference is being assigned, Only values ​​can you wrap it in a class:

  public square IntegerHolder {Private int value; Public integerhold (int value) {this.value = value; } Public Zero Enhance () {value ++; } ...}  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -