HI I am a new java programmer (very new).
What I want to do/test is (not sure if its recommendable or doable?), we know that
System.out.println("Message");
will output the “Message” in command prompt. Is it possible to display the current time, without having to repeatly use the system.out.println()?
Name, like instead of displaying:
10:00:01
10:00:02
10:00:03
I wand to have liek this:
10:00:0X where X will continue counting
If you emit a
\r(carriage-return) instead of a\n(line-end), in most terminals, the cursor will go back to the start of the same line, so you can “overwrite” the line next time.printlnautomatically adds a\n, but you can useSystem.out.print(without thelnpart;-) to avoid that (you may also have to call methodflushto make sure everything you printed was actually output, as opposed to being held in a memory buffer).