Static Keyword

Java static keyword

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

The static can be:

  1. Variable (also known as a class variable)
  2. Method (also known as a class method)
  3. Block
  4. Nested class

Java static variable

If you declare any variable as static, it is known as a static variable.

Advantages of static variable

It makes your program memory efficient (i.e., it saves memory).