1  /**
  2     This example demonstrates local variables.
  3  */
  4  public class Counter
  5  {
  6     private int value; // value is instance variable
  7  
  8     /**
  9        Advances the value of this counter by 1.
 10     */
 11     public void click() 
 12     {
 13        int updatedValue = value + 1;
 14           // updatedValue is a local variable
 15        value = updatedValue;
 16           // updatedValue is forgotten here
 17     }
 18  
 19     /**
 20        Resets the value of this counter to a given value.
 21     */
 22     public void resetTo(int newValue) 
 23        // newValue is a parameter variable
 24        // newValue is initialized with the argument of a method call
 25     {
 26        value = newValue;
 27           // newValue is forgotten here     
 28     }
 29  
 30     /**
 31        Gets the current value of this counter.
 32        @return the current value
 33     */
 34     public int getValue()
 35     {
 36        return value;
 37     }
 38  }