Basic For Loop

This is an simple example of a for loop. It prints a line of asterisks.

import java.awt.* ;
import java.applet.Applet;
public class Asterisk extends Applet
{

public void paint(Graphics g)
{

int count;
int x = 10;
for (count = 0; count < 10; count++)
{

g.drawString("*", x, 30);
x = x + 10;

}

}

}

This is the output:

asterisks.JPG
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License