PDA

View Full Version : Differentiate between static and nonstatic members in java 2011



saneha
04-27-2011, 11:02 PM
Differentiate between static and nonstatic members.

Vuhelper
04-27-2011, 11:03 PM
Static variables and methods are associated with the class itself and are not tied to any particular object. Therefore static's can be accessed without instantiating an object. Static methods and variables are generally accessed by class name.

The most important aspect of static's is that they occur as a single copy in the class regardless of the number of objects. Static's are shared by all objects of a class.

Non static methods and instance variables are not accessible inside a static method because no this reference is available inside a static method.