I Know that in Java, Integer is an immutable object. but I need a way to be able to change an integer in a method and see the change outside the method. For example:
int getInt(){
int my_int=0;
test(my_int);
}
void test(int i){
i=3;
}
What I want to see as the output of getInt
is 3
not 0
.
Is there any way to do that?
my method is more complicated than what I wrote, and it will return another object. That's why I want to change the int in the input and not return it.