I have been learning C and now I want to compare it to Java
If I do this
void changeVal(int x){
++x;
}
in C that only changes the value of x stored in the stack frame. It changes the local copy of xonly.
So what does
int x = 5;
public void changeValJava(int x){
++x;
}
do in Java?
Does it change the value of x or the value of an instance of x?
In C we would need to use a pointer to x to change the actual value, but what about in Java?