Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 5.9</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet9.class" WIDTH=500 HEIGHT=500> </APPLET> </BODY> </HTML>
Applet listing:
/* Simple applet to demonstrate arrays */ import java.awt.*; import java.applet.Applet; public class Applet9 extends Applet{ String[] dayOfTheWeek = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; String[] ordinalNumber = {"first","second","third","fourth","fifth","sixth","seventh"}; Font f = new Font("TimesRoman",Font.BOLD,16); public void init() { setBackground(Color.white); } public void paint(Graphics g) { g.setFont(f); g.drawString("The "+ordinalNumber[0]+" day of the week is "+dayOfTheWeek[0], 10 , 20); g.drawString("The "+ordinalNumber[1]+" day of the week is "+dayOfTheWeek[1], 10 , 40); g.drawString("The "+ordinalNumber[2]+" day of the week is "+dayOfTheWeek[2], 10 , 60); g.drawString("The "+ordinalNumber[3]+" day of the week is "+dayOfTheWeek[3], 10 , 80); g.drawString("The "+ordinalNumber[4]+" day of the week is "+dayOfTheWeek[4], 10 ,100); g.drawString("The "+ordinalNumber[5]+" day of the week is "+dayOfTheWeek[5], 10 ,120); g.drawString("The "+ordinalNumber[6]+" day of the week is "+dayOfTheWeek[6], 10 ,140); } }