NestedForLoop.java


/* This example will demonstrate the FOR LOOP
< applet
code=NestedForLoop
width=200
height=260 >
< /applet >
*/

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

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


  public boolean action (Event thisEvent, Object thisObject)
  {
    
	  for (int n=0; n<4; n++)
	  {
		  Result.appendText("n="+n+" (outer loop) \n");
		  for (int k=7; k > 5; k--)
			  Result.appendText("k + n = "+(k + n)+" (inner loop)\n");
	  }


	  return true;

  }
}


Output for NestedForLoop.java