As it is said in one of the post also that
* static variables are class variables
* They are accessed only by class and not class instances
* static variables are accessible from static methods and classname
class StaticDemo{
static int a=90;
static int b;
static {
System.out.println("Static block initialised ");
b=a/2;
}
static void meth(){
System.out.println("the value of a and b is :" + a + " " + b );
}
}
class StaticTry{
public static void main(
String args[]){
StaticDemo ob = new StaticDemo();
ob.meth();
System.out.println(ob.b);
StaticDemo.meth();
}
}
but in the above program i can access from class instance also Why ? please explain as i am a beginner