Static is a keyword in Java, which is used for
Static can not be used for Outer most class class. Why?
- static blocks
- variables
- methods and
- inner classes or nested classes
- A static member can be accessed directly with the class name with out creating an object.
- The value of the static variable is shared by all objects of a class means same set of copy available to all the objects.
- If any variable is modified by an object those changes visible to every object. Static content doesn't belongs to any particular instance or object.
- Every class is already common to all the objects. No need to make class static to become available to all the objects
- A class is belongs to package level. Class can be accessed directly with <package_name.ClassName>. No need to make class as static.
0 comments:
Post a Comment