The while loop in Java

// This is the Hello program in Java
 
 class Hello {
 
   public static void main (String args[]) {
    
     System.out.print("Hello ");   // Say Hello
     int i = 0;  // Declare and initialize loop counter
     while (i < args.length) { // Test and Loop
       System.out.print(args[i]);  
       System.out.print(" ");
       i = i + 1;     // Increment Loop Counter
     }
     System.out.println();  // Finish the line
  }
 
}

Previous | Next | Top | Cafe au Lait

Copyright 1997 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified July 14, 1997