In my class, I have field int count. I want to create a new variable according to value of count variable, like this: int a = new Integer(count). But when I update count variable: count++, then variable a also gets updated. So how to create non-referencing int variable?
In my class, I have field int count . I want to create a
Share
You can’t do this with Java. Your closest bet would be to create an enclosing class with a single int, and refer to that instead:
Then, later:
But: this breaks a bunch of commonly-accepted best practices in Java. You might look for an alternative way to solve whatever your real problem is.