

// variables have names, types, scope and lifetime.
// lifetime happens when the program runs.
// a Frame is created when a method runs, and in the
// Frame are place all local variables. When the
// method retuns, its Frame is destroyed.

class LifetimeExample
{

   public static
   void main ( String [] args )
   {
       int i = 3 ;
       i = f(2) ;
       System.out.println(i) ;
   }

   static
   int f ( int k ) 
   {
      // next line, lifetime of (f's) i begins
      int i = 1 ;
      return k+i ;
      // previous line, lifetime of (f's) i ends
   }


}

