import java.util.*; class UseArrayListsRec1 // Demonstrates a method which returns the largest integer in an ArrayList of // integers. This method shows the use of tail recursion where the algorithm // would normally be implemented using iteration. { public static void main(String[] args) throws Exception { Scanner input = new Scanner(System.in); System.out.println("Enter some numbers (all on one line, separated by spaces):"); String line = input.nextLine(); String[] numbers = line.split(" +"); ArrayList a = new ArrayList(); for(int i=0; i a) { return biggest(a,a.get(0),1); } private static int biggest(ArrayList a,int biggestSoFar,int i) { if(ibiggestSoFar) return biggest(a,n,i+1); else return biggest(a,biggestSoFar,i+1); } else return biggestSoFar; } }