Introduction to Variables in java | Core Java Tutorials

This Core Java Tutorials “Introduction to Java Variables” post is providing an introduction to variables including definition, the difference between static and non-static variable.



  • Named memory location.
  • For every Application data storage and processing in essential thing.
  • We can store information into memory.
  • Providing identity to memory location is called Variable.
  • Without identities we cannot access the data once it has been stored.
  • Using variables we can process the information effectively.


Static v/s Non-static variable:

  • As a programmer first we need to know whether the variable need to be declared as static or non-static.
  • Variables which are common for all the objects must be declared as static, for example bank_name in the application.
  • Variables which are specific to Object must be defined as non-static, for example acc_no in the application.
  • Static variable get memory allocation only once(share the data).
  • Non-static variables get memory allocation inside every object(no data share).
  • Look at the example to get clarity.

Share this