Java Display Numerical Values in Applet

In applets, we can display numerical values by first converting them into strings and then using the drawstring() method of Graphics class we can do this easily by calling the valueOf() Method of String class.


import java.awt.*;
import java.applet.*;
public class DisplayNumericalValues extends Applet
	public void paint(Graphics g)
		int val1 = 10;
		int val2 = 20;    	
		int sum = val1 + val2;
        String str_sum = "Sum="+String.valueOf(sum);

This applet runs using the following HTML file:

	<TITLE>Display Numerical Values</TITLE>
	<APPLET Code="DisplayNumericalValues.class" Width=400 Height=300>

Share this article on