how to use \r in Java properly for Count Down Timer? i want to count down from 20 to 0 and print this, i want to update this instead of writing in new line so i used \r . it works, but when it comes to 10, then after this, instead of writing 9 it writes 90, 80 and so on... plz update my code to solve problem. thanks here is my code
int timer1=20;
int timer2=0;
String timer3="\r";
while(timer1>timer2){
try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
System.out.print(timer3+timer1);
System.out.flush();
timer1--;}