this: is called as reference variable because it always refer an current object.
Eg:
Is this valid ?
Obj is local variable i.e we can't access that variable outside main method.
In above code snippet value is a instance variable.
So we must need an object or object or object reference to access value;
Then still valid the above snippet ?
Eg:
Is this valid ?
public class MleClass{
int value=10;
void show(){
System.out.println(value);
}
public static void main(){
MleClass obj =new MleClass();
ob.show();
}
}
Obj is local variable i.e we can't access that variable outside main method.
In above code snippet value is a instance variable.
So we must need an object or object or object reference to access value;
Then still valid the above snippet ?