Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Last active December 20, 2015 12:09
Show Gist options
  • Save sasaki-shigeo/6128991 to your computer and use it in GitHub Desktop.
Save sasaki-shigeo/6128991 to your computer and use it in GitHub Desktop.
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
}
}
}
}
}
@sasaki-shigeo
Copy link
Author

ストップウォッチ・プログラム
プログラム実行開始からの経過時間を hh:mm:ss で表示
8行目の printf の \n を \r に変えると,同じ場所で時刻表示が変化する。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment