Normally, members of a class must be accessed only in conjunction with an object of its class as shown in the below examples:
- object1.volume; -> Accessing instance variable ‘volume’ using ‘object1’ object
- object1.volume( ); -> Accessing volume( ) method using ‘object1’ object
public static void main(String args)
Instance variables declared as ‘static’ are essentially global variables. When objects of its class are declared, no copy of static variable is made. Instead all the objects of the class share the same instance variable.
In order to access the static instance variables outside its class, we have to access them as ClassName.InstanceVariableName
Example:- Test.a; (Here Test is a…
View original post 435 more words