Every non static variables which are not located inside blocks or in main method called Instance variables. These variables are belong to a class.
Ex -:
These variables can not access in normal way. Just try below example.
class Instance{
int x =10;
public static void main(String args[]){
System.out.println(x);
}
}
To access these variables we need to create objects from the class(I'll explain you these things in detail when I am doing Object Oriented Programming. Just follow the examples and get an idea ).
see its working. Now you have brief idea about main four variables in JAVA.
Now try your self to use all these variable in a single class.
-Thank you-




Brilliant.............. keep it up!!!!!!
ReplyDelete