View Single Post
  #1 (permalink)  
Old June 28th, 2006, 03:06 AM
prakash.suthar prakash.suthar is offline
Registered User
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default static field with class instance

Static variable is class variable and all the instance (object) of class share the single copy of static. It is none of use to call the static variable with class instance (object), though we can call.
I just wanted to know that how this functionality is achieved.
1.When class is loaded in memory, class variable i.e. static variable is created and when the instance (object) of that class is created, reference of that static variable is passed to the class instance (object)…
2.At runtime, when static variable is used, compiler check that instance of which class invoke the static variable, and after identification compiler use the static variable from class memory…
So, what happens actually, either of two above or something else is happened when we call like “obj.staticfield”?