import java.io.*; class Numbers7 { // Demonstrating "higher order functions" in Java - map static final int SENTINEL = -999; static final int MAXNUMS = 100; public static void main (String[] args) throws IOException { int [] data; int count,n; BufferedReader in = Text.open(System.in); data = new int[MAXNUMS]; for(count=0; ;count++) { System.out.print("Enter number "+(count+1)+" (or "); System.out.print(SENTINEL+" to finish): "); n=Text.readInt(in); if(n==SENTINEL) break; data[count]=n; } System.out.println("The numbers entered were:"); NumberOps.printall(data,count); System.out.println("After mapping square onto the array it is:"); Higher.map(new Square(),data,count); NumberOps.printall(data,count); System.out.print("Enter a number: "); n=Text.readInt(in); System.out.print("After mapping add("+n+") onto "); System.out.println("the array it is: "); Higher.map(new Add(n),data,count); NumberOps.printall(data,count); } }