how to print hello world every second till i have pressed
enter key ???
Answer / core
import java.util.Scanner;
public class InfiniteThread extends Thread {
public void run() {
while (true) {
System.out.println("hi");
try {
this.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args) throws InterruptedException {
new ExitThread().start();
new InfiniteThread().start();
}
}
class ExitThread extends Thread{
@Override
public void run() {
Scanner scan = new Scanner(System.in);
String next = scan.nextLine();
if(next.equals(""))
System.exit(0);
super.run();
}
}
Is This Answer Correct ? | 15 Yes | 4 No |
Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.
How to transfer data from an Applet to Servlet ?
Is there any need to import java.lang package?
What state is a thread in when it is executing?
Can we assign the reference to this variable?
Why string is not thread safe?
Is 0 an even number?
Same common question what is Map,Set,HashMap,List????
Is age a discrete variable?
Does java allow overriding static methods ?
Why parsing is done?
What are different types of classloaders?