Static Variable in Java | Java Tutorials

This Java Tutorials “Static Variable in Java” page explains clearly what is static variable , where static variable gets memory allocation, how to access static variable and much more in java application.


Static variable:

  • Declaration of variable inside a Class and outside to Methods and Blocks.
  • We must use static keyword in its declaration.
  • We can initialize static variable directly, for example “static int a=100”.
  • We can access static variables in the application using “class name”.
  • Static variable can be accessed anywhere in the application.


  • Static variable get memory allocation in JVM’s Method area.
  • Static variables automatically initializes with default values depends on data type.

Default_values in Java


Program to print all the default values of data types:


Share this