Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

For loop act as while loop (Java)



*******************************************************************
COMPLETE SOURCE CODE FOR : ForActAsWhile.java
*******************************************************************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");
  }
}
}

*******************************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************************