/* Loops1.java CIS 160 David Klick 2004-09-17 Demonstrates some simple repetition/loops (counter controlled) */ public class Loops1 { public static void main(String[] args) { int i; // this is called a post-test loop because the test // is at the end of the loop System.out.print("\nA do loop: "); i = 1; do { System.out.print(i + " "); i++; } while (i <= 10); // this is called a pre-test loop because the test // is at the beginning of the loop System.out.print("\nA while loop: "); i = 1; while (i <= 10) { System.out.print(i + " "); i++; } // the for loop is also a pre-test loop System.out.print("\nA for loop: "); for (i=1; i<=10; i++) { System.out.print(i + " "); } } }