Hello World Program

Hello World Program

write a java program that continuously prints HelloWorld! to the screen(once every second ) and exists when press the enter key

View Answers

December 20, 2010 at 5:39 PM

Hi Friend,

Try the following code:

public class DisplayMessageContinuously extends Thread {
  private String st;          
  private long delay;              

  public DisplayMessageContinuously(String st, long delay) {
    this.st = st;      
    this.delay = delay;                  
    setDaemon(true);                 
  }

  public static void main(String[] args) {
    Thread th = new DisplayMessageContinuously("Hello World ", 1000);
    th.start();                      
    try {
      System.in.read();                
      System.out.println("Enter pressed...\n");

    } catch (Exception e) {          
      System.out.println(e);            
    }
    return;
  }
  public void run() {
    try {
      while(true) {                         
        System.out.println(st);         
        sleep(delay);                       
       }
    } catch(Exception e) {       
      System.out.println(e);    
    }
  }
}

Thanks


December 20, 2010 at 7:58 PM

Thanks


December 20, 2010 at 7:58 PM

Thanks

Ads









Related Tutorials/Questions & Answers:
Hello world program
Hello world program  hello world program   class Hello{ public static void main(String[] args) { System.out.println("Hello World"); } } For more information, visit the following link: http
Hello World Program
Hello World Program  write a java program that continuously prints HelloWorld! to the screen(once every second ) and exists when press the enter key... = new DisplayMessageContinuously("Hello World ", 1000); th.start
Advertisements
writing angularjs hello world program
hello world program. Just tell me best tutorial for learning AngularJS quickly...writing angularjs hello world program  Hi, I just started to learn... tutorials. I want to make simple program and thinking to start from the Hello
AngularJS Hello World Program
AngularJS Hello World Program - Create and run your first AngularJS example.... Step 2: Writing AngularJS Hello World Program We have downloaded... on the following link: Download AngularJS Hello World Program example html page
How to create Bootstrap Hello World program
of Hello World Bootstrap program. How to create Bootstrap Hello World program..., install and create hello world program in Bootstrap 4. Thanks...How to create Bootstrap Hello World program  Hello guys, I am
How to create Bootstrap Hello World program
of Hello World Bootstrap program. How to create Bootstrap Hello World program..., install and create hello world program in Bootstrap 4. Thanks...How to create Bootstrap Hello World program  Hello guys, I am
Hello world (First java program)
Hello world (First java program)   ... program is very simple. To write the Hello world program you need  simple... for compiling and running. Hello world program is the first step of java
Hello World Program in TensorFlow
Writing and running Hello World Program in TensorFlow After installation... series and first create famous Hello World program. We will write and run TensorFlow Hello World program. TensorFlow is machine learning and distributed
Hello World Program in TensorFlow
Writing and running Hello World Program in TensorFlow After installation... series and first create famous Hello World program. We will write and run TensorFlow Hello World program. TensorFlow is machine learning and distributed
Hello World Program in TensorFlow
Writing and running Hello World Program in TensorFlow After installation... series and first create famous Hello World program. We will write and run TensorFlow Hello World program. TensorFlow is machine learning and distributed
Hello World Program in TensorFlow
Writing and running Hello World Program in TensorFlow After installation... series and first create famous Hello World program. We will write and run TensorFlow Hello World program. TensorFlow is machine learning and distributed
How to write hello world example program in Hibernate?
How to write hello world example program in Hibernate? Hello World tutorial.... Writing Hibernate hello world program In this section, you will learn about basic... table and finally printing the famous "hello world" message on the console
Hello world
Hello world (First java program)   ... and can be run on any operating System. Writing Hello World program is very simple. To write the Hello world program you need  simple text editor like note
Struts 2 Hello World Example
Struts 2 Hello World Example - Video Tutorial that shows how to create Hello World example program in Eclipse IDE. In this video tutorial I will teach you how to develop 'Hello World' application in Struts 2 framework. We
Python Hello World Example
the Hello World program in python shell. Open terminal in your Ubuntu Operating...Python Hello World Example - Writing and testing First Python Hello World... Python program. This is a simple tutorial, which is easy to learn "Hello
Python Hello World Example
the Hello World program in python shell. Open terminal in your Ubuntu Operating...Python Hello World Example - Writing and testing First Python Hello World... Python program. This is a simple tutorial, which is easy to learn "Hello
ModuleNotFoundError: No module named 'hello-world'
ModuleNotFoundError: No module named 'hello-world'  Hi, My Python... 'hello-world' How to remove the ModuleNotFoundError: No module named 'hello-world' error? Thanks   Hi, In your python environment
Android Studio Hello World Tutorial
Studio. So, this is how you can create your own hello world program in Android...Android Studio Hello World Tutorial - Learn application development using Android Studio IDE Video tutorial on developing Hello World Example using Android
Getting exception in hello world
Getting exception in hello world  I run your hibernate5 "hello world" program. But, getting an exception: ERROR: Table 'mydb.employee' doesn't exist Exception in thread "main" javax.persistence.PersistenceException
Getting exception in hello world
Getting exception in hello world  I run your hibernate5 "hello world" program. But, getting an exception: ERROR: Table 'mydb.employee' doesn't exist Exception in thread "main" javax.persistence.PersistenceException
Servlet hello world example
by making Servlet hello world program. We will just write one program which print hello world in Servlet. Let us explain this by a hello world example using Servlet...Servlet  hello world example This tutorial will help you to understand
jQuery to "Hello World"
the Hello World  program Step 1: Create php file to that prints the current...;? print $hello_world="Hello World"; ?> Step 2: Write HTML page to call... jQuery to "Hello World"     
J2ME Hello World Example
J2ME Hello World Example       This is the simple hello world application. In this example we...;Hello World!!!!!!!" as below:  Form form = new Form("
Creating Hello World JSP Page
Creating Hello World JSP Page  Hi, I am trying to create Hello World example in JSP. How to create Hello World JSP page? Thanks   Hi.... Then ad some code to it. You may add following code : <%="Hello World!" %>
TensorFlow 2.0 Hello World
of TensorFlow 2.0 Hello World program: import tensorflow as tf msg... Hello World program execution: Above example shows the execution of TensorFlow 2.0 Hello World program. In TensorFlow 2.0 session has been removed
TensorFlow 2.0 Hello World
of TensorFlow 2.0 Hello World program: import tensorflow as tf msg... Hello World program execution: Above example shows the execution of TensorFlow 2.0 Hello World program. In TensorFlow 2.0 session has been removed
EJB Hello world example
EJB Hello world example      ... example we are going to show you, how to create your first hello world example in EJB and testing it. You can also create a hello world example to test your
JSP Hello World
JSP Hello World We are going to discus about JSP hello world. In this example we are create "HelloWold" on web browser. In this program of JSP instances. we can print simple "Hello World" String on web browser
Writing Hello World
Writing Servlet Hello World      ... the beginning. Lets start by making one program which will just print the "Hello... of: "How to create Hello World Servlet in Eclipse?" Whenever the user
pring Hello World Application
Spring Hello World Application       Hello World Example using Spring, The tutorial given below describes you the way to make a spring web application that displays Hello World
How to create Applet Hello World?
How to create Applet Hello World?  Hi, What is Applet in Java? How to create Applet Hello World? Thanks   Hi, Applet is Java Program..." WIDTH=700 HEIGHT=500> Java - Applet Hello World. Thanks

Ads