Pages

For loop act as while loop


public class ForActAsWhile
{
public static void main(String[]args)
{
/*
* while(true)
* {
* System.out.println("HELLO WORLD");
* }
*
*
*Now we will create for loop
*that will act like while loop at above
*/

/*
*For loop at below is an unstopable loop.
*It will act like while loop at above.
*It has no i++ at last.So (i) value is always 0.
*And 0 is less then 1.This condition is always true.
*NOTE : <<DON'T EXECUTE IT!!>>.This is only for learning.
*/
for(int i=0;i<1;)
{
System.out.println("HELLO WORLD");
}
}
}

Related Posts Plugin for WordPress, Blogger...