Static Method Example In Java1 min read

Java Code:


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).

Static methods in Java can be called without creating an object of class.

The static keyword in java is used for memory management mainly. We can apply java static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of the class.

The static variable gets memory only once in class area at the time of class loading.

Leave a Comment