/* This shows the use of nested loops */ public class nestedloop { public static void main(String args[]) { // iterator variables int i; int j; System.out.println("All combinations of two Dice (d1, d2):"); // assume we have two dice, and order matters // print out all possible combinations // two dice, two loops i = 1; while(i < 7) { // notice the loop will stop when i reaches 7 j = 1; while(j <= 6) { // notice a different way of writing the same condition System.out.println(i+" "+j); j++; } i++; // make sure to keep track of which variables go in which loop! } } }