Lets take an example of for loop:
class remote
{public static void main(String b[])
{
for(int a=0; a<=10; a++)
{
System.out.println(a);
}
}
}
If you execute this program you will show that the numbers for 0 to 10 and if the condition will false the body will terminate.Now let's some changes in above example print statement out of loop :
class remote
{public static void main(String b[])
{
for(int a=0; a<=10; a++)
{
System.out.println(a);
}
System.out.println(a);
}
}
class remote
{public static void main(String b[])
{
for(int a=0; a<=10; a++)
{
System.out.println(a);
}
}
}
If you execute this program you will show that the numbers for 0 to 10 and if the condition will false the body will terminate.Now let's some changes in above example print statement out of loop :
class remote
{public static void main(String b[])
{
for(int a=0; a<=10; a++)
{
System.out.println(a);
}
System.out.println(a);
}
}
what is the output of this program for more examples comment me ....🙂🙂🙂
No comments:
Post a Comment