Sponsered Links
Categories
Sponsered Links

While Loop in java

 

 This example illustrates how to create the while loop in java.

A Java while loop is a looping construct which continually executes a block of statements while a condition remains true. When condition becomes false, control passes to the next line of code immediately following the loop. Here is a while loop example that prints up to 100

 Source Code of whileloop.java

class whileloop{
  public static void main(String[] args){
    int i=Integer.parseInt(args[0]);
    while(i<=100){
      if(i%2==0){
        System.out.println("number is even"+i);
      }
      else{
        System.out.println( "number is odd"+i);
      }
      i++;
    }
  }
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved