import java.io.*; class SortIntArrayIt4 { public static void main(String[] args) throws IOException // Illustrates use of recursion to read a number of integers into // an array, without specifying how many in advance { int n; int[] array; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); array = readInts(0,in); System.out.println("The array you entered is:"); System.out.println(arrayToString(array)); sort(array); System.out.println("After sorting, the array is:"); System.out.println(arrayToString(array)); } public static int[] readInts(int count,BufferedReader in) throws IOException { System.out.print("Enter integer "+count+" or new line to halt: "); String line=in.readLine(); if(line.equals("")) return new int[count]; else { int n = Integer.parseInt(line); int[] a = readInts(count+1,in); a[count]=n; return a; } } private static String arrayToString(int[] a) { String str="["; if(a.length>0) { str+=a[0]; for(int i=1; i