Answer to Question #46740 in Java | JSP | JSF for Kishore Kumar
java programme which will print the current time on the console every two seconds after doing this activity for 20 seconds the program quits.
1
2014-09-24T12:20:45-0400
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!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment