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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -