Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 5.5</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet5.class" WIDTH=500 HEIGHT=500> </APPLET> </BODY> </HTML>
Applet listing:
/* This applet demonstrates the different types of numbers in Java */ import java.awt.*; import java.applet.Applet; public class Applet5 extends Applet{ byte myByte = Byte.MAX_VALUE; short myShort = Short.MAX_VALUE; int myInt = Integer.MAX_VALUE; long myLong = Long.MAX_VALUE; float myFloat = Float.MAX_VALUE; double myDouble = Double.MAX_VALUE; 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 maximum value of a byte is: "+this.myByte, 10 , 20); g.drawString("The maximum value of a short is: "+this.myShort, 10 , 40); g.drawString("The maximum value of an integer is: "+this.myInt, 10 , 60); g.drawString("The maximum value of a long is: "+this.myLong, 10 , 80); g.drawString("The maximum value of a float is: "+this.myFloat, 10 , 100); g.drawString("The maximum value of a double is: "+this.myDouble, 10 , 120); } }