Program to display numbers from 1 to 10 on Applet such that each number will be display after delay of 100 ms

This makes the use of Thread's sleep( ) method which causes currently executing thread to sleep for given number of milliseconds. In output it will print the numbers from 1 to 10 with a delay of 100ms.

import java.awt.*;  // import awt package
import java.applet.*; // import applet package

public class Print1To10Num extends Applet 
    public void paint(Graphics g)
        for(int i=1;i<=10;i++)
       g.drawString(i+"",20,10*i); // display message on applet
       catch(InterruptedException e){}
/*  <applet code=Print1To10Num.class height=300 width=250>



Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

Program to input age from user and throw user-defined exception if entered age is negative