// the tower of Hanoi problem class RecursiveEx1 { static int disks = 3; public static void main (String[] args) { Hanoi (disks, 'A', 'B', 'C'); } public static void Hanoi (int numberOfDisks, char from, char temp, char to) { if (numberOfDisks == 1) System.out.println ("Disk 1 moved from " + from + " to " + to); else { Hanoi (numberOfDisks-1, from, to, temp); System.out.println ("Disk " + numberOfDisks + " moved from " + from + " to " + to); Hanoi (numberOfDisks-1, temp, from, to); } } }