The complete program is given below.
Notice that the two for loops are the same.
This is very common.
It would be nice to copy this program to a file and to run it.
When you do this,
change the length of the array and note the effect.
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 ( int index=0; index < array.length; index++ )
{
System.out.println( "enter an integer: " );
data = Integer.parseInt( inData.readLine() );
array[ index ] = data ;
}
// write out the data
for ( int index=0; index < array.length; index++ )
{
System.out.println( "array[ " + index + " ] = " + array[ index ] );
}
}
}