Array2.java


/*Array2.java
This applet will demonstrate how to retrieve integers from
an HTML document and place those integers into a one-dimenstiona array.

< applet
code=Project10B
width=200
height=200 >
< param name=hm value=3 >
< param name=num1 value=10 >
< param name=num2 value=7 >
< param name=num3 value=4 >
< /applet >
*/


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

public class Array2 extends Applet
{
	int data[]=new int[5];
	TextArea result=new TextArea(10, 25);

	public void init()
	{
		
		add(result);
	}

	public void start()
	{
		
		
           // retrieving interger from HTML
		  short howmany =(short)Integer.parseInt(getParameter("hm"));

		  for (int k = 0; k < howmany; k++)
		    data[k] = Integer.parseInt(getParameter("num"+Integer.toString(howmany-k)));

		  /*The two lines above are equalvalent to the next 3 lines.	
		  data[0] = Integer.parseInt(getParameter("num3"));
		  data[1] = Integer.parseInt(getParameter("num2"));
		  data[2] = Integer.parseInt(getParameter("num1"));*/
		
		
		for (int i = 0; i < howmany; i++)
           result.appendText("data["+i+"] = "+data[i]+"\n");

	}

}


Output for Array2.java