import java.util.*; class UseArrayListsRec4 // Demonstrates a method which returns the largest integer in an ArrayList. // The method is implemented using recursion which reduces the problem size // for the recursive call by calling subList. { 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) { int n = a.get(0); if(a.size()==1) return n; else { int biggestInRest = biggest(a.subList(1,a.size())); if(biggestInRest>n) return biggestInRest; else return n; } } }