/** * Loops.java * Jeff Ondich, Carleton College, 2014-01-05 * * Demonstrates a few simple loops. * * This is the Java half of a pair of parallel examples in Python and Java. * See loops.py. */ public class Loops { public static void main(String[] args) { System.out.println("Counting up with a while-loop"); int m = 0; while (m < 5) { System.out.println(m); m++; } System.out.println("Counting up with a for-loop"); for (int k = 0; k < 5; k++) { System.out.println(k); } System.out.println("Counting down with a for-loop"); for (int j = 5; j > 0; j--) { System.out.println(j); } } }