// ArrayOneDimension1.java
// Using a for loop to process a simple array
// APPLET CODE="ArrayOneDimension1" HEIGHT=250 WIDTH=300
import java.awt.*;
import javax.swing.*;
public class ArrayOneDimension1 extends JApplet {
// hard-coded array
String finStudents[ ] = { "Slane", "Johnston", "Burke", "Robak", "Snyder", "Patel" };
// GUI Components
Container c;
JTextArea outputArea;
public void init( ) {
c = getContentPane( );
outputArea = new JTextArea( 6, 40 );
c.add( outputArea );
showOutput( );
}
public void showOutput( ) {
outputArea.append( "Student\tName" );
for ( int i = 0; i < finStudents.length; i++ )
outputArea.append( "\n " + ( i + 1 ) + "\t" + finStudents[ i ] );
}
}