Array1.java


/*Array1.java

This applet will demonstrate how to fill and dump a one-dimensional array.


< applet
code=Array1
width=200
height=200 >
< /applet >
*/

import java.applet.*;
import java.awt.*;

public class Array1 extends Applet
{
  Button Calculate = new Button("Calculate");
  TextArea result = new TextArea(8,25);

  public void init()
  {
        setBackground(Color.black);
	setForeground(Color.red);  
	add (Calculate);
	add(result);

   }

public boolean action (Event thisEvent, Object thisObject)
{
    
	
	Font troman = new Font("TimesRoman", Font.ITALIC, 12);
	result.setFont(troman);
	int num[];
	
	num = new int[10];
	//Fill array
	for(int k = 0; k <= 4; k++)
		num[k] = (25 / (k+ 1)) + (25 % (k + 1) ) - 3 * k ;
		
	
	//Dump Array	
	for (int j = 0; j <= 4; j++)
		result.appendText("num["+j+"] = "+num[j]+"\n ");
  
  return true;
}
}


Output for Array1.java