In most cases, you can print a carriage return ( \r ) rather than a new line ( \n ). It depends on the terminal supporting it, which is most important. \r moves the cursor back to the beginning of the line.
EDIT: Obviously, use System.out.print , not System.out.println (or just use the regular form, not ln , the output method you use) - since ln suffix means your text will be automatically followed new line.
Example:
for (n = 10000; n < 10010; ++n) { System.out.print(String.valueOf(n) + "\r"); } System.out.println("Done");
When this ends, you will probably get this on the console screen:
Done0
... since "Finish" is shorter than the longest previous thing that you output, and therefore does not completely overwrite it (hence, 0 at the end remaining from "10010"). So, the lesson: keep track of the longest entry and rewrite it with spaces.
source share