What they really mean in K&B is this ,
Forget abt where the static variable is stored ,
just remmeber that there is only one copy and there are several ways
to access it
Consider the following ,
class Static
{
static int a;
{
public static void main(
String args[])
{
System.out.println(a); //prints 0
System.out.println(Static.a); //prints 0
System.out.println(new Static().a); //prints 0
///this is my favorite
Static variable =null;
System.out.println(variable.a); //prints 0 , no NullPointerException!!!
Static var1=new Static();
Static var2=new Static();
var1.a=10;
var2.a=20;
////this proves that there is only one copy
System.out.println(var1.a); //prints 20
}}
Again , there are several ways to refer to a static variable
but there is only copy
Hope i hav cleared ur doubt
santhosh sharma (
scjp 1.4 100%)