ForLoop.java


/*ForLoop.java 
This example will demonstrate the FOR LOOP

< applet
code=ForLoop
width=200
height=225 >
< /applet >

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

public class ForLoop extends Applet
{
  Label Line1 = new Label("This applet will demonstrate the for loop");
  Button ShowIt=new Button("Go");
  TextArea Result=new TextArea(9,30);
  public void init()
  {
  add(Line1);
  add(ShowIt);
  add(Result);
  }


  public boolean action (Event thisEvent, Object thisObject)
  {
    
	  int b = 2;
	  for (int n=0; n<3; n++)
		  Result.appendText(" n = "+n+" with this pass through the loop \n");
	  for (int k=8; k> 5; k--)
	  {
                 b += k;
		 Result.appendText("b= "+b+" \n");
		 Result.appendText("k= "+k+" \n");
	  }

	  return true;

  }
}


Output for ForLoop.java