// ArrayOneDimension2.java
// Using a for loop to process a simple array
// APPLET CODE="ArrayOneDimension2" HEIGHT=450 WIDTH=300
import java.awt.*;
import javax.swing.*;

public class ArrayOneDimension2 extends JApplet {
        String finStudents[ ];
        // GUI Components
        Container c;
        JTextArea outputArea;

        public void init( ) {
                // GUI Components
                c = getContentPane( );
                outputArea = new JTextArea( 6, 40 );
                c.add( outputArea );

                // create the array
                finStudents = new String[ 6 ];

                // display elements initialized to null
                showOutput( );

                // fill array with data
                finStudents[ 0 ] = "Slane";
                finStudents[ 1 ] = "Johnston";
                finStudents[ 2 ] = "Burke";
                finStudents[ 3 ] = "Robak";
                finStudents[ 4 ] = "Snyder";
                finStudents[ 5 ] = "Patel";

                // display elements containing data
                showOutput( );
        }

        public void showOutput( ) {
                outputArea.append( "\n\nStudent\tName" );
                for ( int i = 0; i < finStudents.length; i++ )
                        outputArea.append( "\n   " + ( i + 1 ) + "\t" + finStudents[ i ] );
                return;
        }
}