Answer to Question #46740 in Java | JSP | JSF for Kishore Kumar

Question #46740
java programme which will print the current time on the console every two seconds after doing this activity for 20 seconds the program quits.
Expert's answer
import java.util.Date;

public class PrintTime {

public static voidmain(String[] args) throws InterruptedException {
long start =System.currentTimeMillis();
while (true) {
Thread.sleep(2000);
System.out.println(new Date());
long finish =System.currentTimeMillis();
if (finish - start>= 20000) {
break;
}
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal