Static Members (Methods, Variables, Static Block and Class)
Static Method
Static Method
In JAVA, Variables can be declared with the "static" keyword.
Syntax: <class-name>.<method-name>
Syntax: <class-name>.<method-name>
Example: Student.getName();
A static method can only call only other static methods, i.e. they cannot call a non-static method from it.
A static method can be accessed directly by the class name and doesn’t need any object to all it.
A static method cannot refer to this or super keywords in anyway.
A static method can access only static data. It can not access non-static data (instance variables)
A static method can only call only other static methods, i.e. they cannot call a non-static method from it.
A static method can be accessed directly by the class name and doesn’t need any object to all it.
A static method cannot refer to this or super keywords in anyway.
A static method can access only static data. It can not access non-static data (instance variables)