Saturday, September 13, 2008

Java 05: While & For Loops Statements



Here is an example of While loop "Hello World" program. Please understand that it is NOT a part of the above video clip. It is provided for education purpose only.

class helloWorld {

public static void main (String args[]) {

System.out.print("Hello World");
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
}

}