Category : Java | Sub Category : Data type, Variable and Arays | By Prasad Bonam Last updated: 2020-09-28 09:38:28 Viewed : 538
/**
*
* 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
}