Last active
December 20, 2015 12:09
-
-
Save sasaki-shigeo/6128991 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StopWatch { | |
| public static void main(String[] args) | |
| throws InterruptedException // thrown by Thread.sleep() | |
| { | |
| for (int h = 0; h < 24; h++) { | |
| for (int m = 0; m < 60; m++) { | |
| for (int s = 0; s < 60; s++) { | |
| System.out.printf("%2d:%02d:%02d\n", h, m, s); | |
| Thread.sleep(1000); // 1000 ms = 1.0 sec | |
| } | |
| } | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ストップウォッチ・プログラム
プログラム実行開始からの経過時間を hh:mm:ss で表示
8行目の printf の \n を \r に変えると,同じ場所で時刻表示が変化する。