for ( int index= egArray.length-1 ; index >= 0 ; index-- )
You probably forgot the -1. Off-by-one errors of this kind are very common. It was an easy bet.
Here is a program that prompts the user for each element and reads it in. The array is hard coded to be five elements long. After it is filled with data, the array is written to the monitor.
import java.io.* ; class InputArray { public static void main ( String[] args ) throws IOException { int[] array = new int[5]; int data; BufferedReader inData = new BufferedReader ( new InputStreamReader( System.in ) ); // input the data for ( ___________ ; ________________ ; _____________ ) { System.out.println( "enter an integer: " ); data = Integer.parseInt( inData.readLine() ); array[ index ] = data ; } // write out the data for ( ___________ ; ________________ ; _____________ ) { System.out.println( "array[ " + index + " ] = " + array[ index ] ); } } }
Usually a program would do something with the data after it was read in. This would usually involve more loops.