Reading
Add Comment
Static method:
It is a method which belongs to the class and not to the object(instance)
A static method can access only static data. It can not access non-static data (instance variables)
A static method can call only other static methods and can not call a non-static method from it.
A static method can be accessed directly by the class name and doesn’t need any object.
Static mehod,block Link
Use:
Static object is used in singleton pattern to make singleton class to make sure that the class have only one instance ...
By using private constructor and a get method to instantiate the class and that class only be instantiate when it doesn't have any object.
What is the difference between a local variable, an instance field, an input parameter, and a class field?
Link

0 comments:
Post a Comment