Sunday 15 December 2013

while loop example in java

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

      int x = 20;

      while( x < 30 ) {
         System.out.print("value of x : " + x );
         x++;
         System.out.print("\n");
      }
   }
}

Output:

value of x : 20
value of x : 21
value of x : 22
value of x : 23
value of x : 24
value of x : 25
value of x : 26
value of x : 27
value of x : 28
value of x : 29

No comments:

Post a Comment

Comment