Thursday, January 13, 2011

Static

Static is a keyword. Static members are access throughout the application.


Static Variable


static variable is a variable whose single copy is available to all the objects if a static variable modified it effects all the objects.


Static Methods


static method is a method .but we are called with out using any object. Methods declared as static have several restrictions. They can only call other static methods. They must only access static data




static variables and methods also access outside of it’s class by using it’s class name. If you avoid this you need to declare static variables or static methods are private. This is called as data hiding from others.



Static use in java

  • Declaring a field belonging to a class

  • Declaring a method belonging to a class

  • Declaring a nested class as static

  • Defining a static class initializing

  • import the static content.

No comments:

Post a Comment