Displaying Numerical values in Applets
https://www.computersprofessor.com/2016/12/displaying-numerical-values-in-applets.html?m=0
Displaying Numerical
values :
In applets ,
we can display numerical values by
first converting them in to
string is then using the
drawString ( ) method of Graphics
class. We can
do this easily by
calling the valueOf ( )
method of String
class.
Program :
import java .
awt.*;
import java . applet
.* ;
public class NumValues extends
Applet
{
public
void paint (
Graphics g)
{
int value1=
10;
int
value2= 20;
int sum= value1+
value2;
String
s = “sum:” + tSring. valueOf (sum);
g.
drawString (5,100,100) ;
}
}
When run
using the following
HTML file displays
the output
<
html >
<
applet >
Code
= NumValues. class.
Width
=300
Height
=300 >
< /
applet >
<
/ html >