Write a program to demonstrates the lifetime of a variable.

Category : Java | Sub Category : Data type, Variable and Arays | By Runner Dev Last updated: 2020-09-28 15:08:28 Viewed : 202


(Data type, Variable and Arays)

Write a program to demonstrates the lifetime of a variable.


/**

 *

 * Write a program to demonstrates the lifetime of a variable.

 */

class LifeTime { // This line daclare a class name

     public static void main(String a[]) { // This line begins the main() method.

           int x; // daclare a variable x.

           for (x = 0; x < 3; x++) { // Declare for loop

                int y = -1; // y is initialized each time block is entered.

                System.out.println("y is: " + y); // this is a output line

                y = 100; // Give value to y

                System.out.println("y is now: " + y); // this is the output line

           } // end of loop function

     } // this line show the main program

}

 OUTPUT:



              

Search
Related Articles

Leave a Comment:
illuttild
at 2022-03-31 04:38:29
[url=https://oscialipop.com]purchasing cialis online[/url] Feline Dosage For Amoxicillin Fkpans Viagra 100mg Canada Pharmacy Pfnlxw <a href=https://oscialipop.com>Cialis</a> Ieziph Cession Clomid https://oscialipop.com - can you buy cialis online Over The Counter Ed Pills Walgreens Fjcddi