For instance,
class ClassOne{
int y = 3
int x = 2
void foo(){
--y;
}
void bar(){
y--;
}
void tesla(){
int y = 10;
}
}
As far as I understand, methods will change class variables in that way:
foo()will do nothing on either variablesbar()will decrease y var by 1, soy=2tesla()will create private or protected variable y which can be accessible only inside thistesla()method.
I am not sure about third one, please comment, did I understand it right?
Both
fooandbarwill decrement the objectsyvariable by one – thus achieve the same effect.teslawill create a local variableyfor that method. You will probably get a warning.