rendered paste bodyimport java.util.Scanner;public class Towers { public class Pole { public int[] _content = new int[0]; public String _name = ""; public Pole(String a) { _name = a; } } public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); Towers hanoi = new Towers(); //Create 3 arrays to hold our data Pole towera = hanoi.new Pole("A"); Pole towerb = hanoi.new Pole("B"); Pole towerc = hanoi.new Pole("C"); System.out.println("How tall is the first tower?"); int ftower = Integer.parseInt(keyboard.nextLine()); doMove(ftower, towerb, towera, towerc);// H_dohanoi(N.intValue(), 3, 1, 2); System.exit(0); } static void doMove(int n, Pole t, Pole f, Pole u) { if (n > 0) { doMove(n - 1, u, f, t); shiftIt(f, t); doMove(n - 1, t, u, f); } } static void shiftIt(Pole from, Pole to) { System.out.print("move "); System.out.print(from._name); System.out.print(" --> "); System.out.println(to._name); } public int get(int[] array) { int newsize = array.length - 1; int top = array[newsize]; array = shrinkArray(array, array.length); return top; } public void add(int[] array, int num) { int size = array.length + 1; array = growArray(array, size); try { array[size] = num; } catch (Exception e) { System.out.println("Oops"); e.printStackTrace(); } } public int[] growArray(int[] array, int size) { int oldSize = array.length; int[] newArray; if (size > oldSize) { newArray = new int[size]; System.arraycopy(array, 0, newArray, 0, oldSize); } else { newArray=array; } return newArray; } public int[] shrinkArray(int[] array, int size) { if (array.length > size) { int oldArray[] = array; array = new int[size]; System.arraycopy(oldArray, 0, array, 0, size); } return array; }}