Variables Declarations




Variable names represent a place in RAM memory where we can store and retrieve value. In the Java programming language we need to specify what type of data can be stored in the memory location.

Example:

Instance variables (available to all methods)
  
   private int x;
   private int y = 5;
   private float z = 17.356;
   public double w = 5.6;
   public String s = "Hello World";



You can also define local (method) variables inside a method. These variables are local to the method only. They are created by the method and destroyed by the method. The variables are only in scope (available) inside the block where they are defined. You cannot use the keywords private, public, or protected on local variables.