I was trying to display a String and then clear it after some time.
The following code is working.
String hello = "Hello";
System.out.print(hello);
int length = hello.length();
for (int i = 0; i < length; i++)
System.out.print("\b");
But when I thought to display it for few seconds (Using Thread.sleep(time)
), it is not working (code below).
When I was debugging it I noticed that after the first execution of the loop, cursor starts pointing to the next line.
So, Is there any way to display for few seconds and then clear it.
String hello = "Hello";
System.out.print(hello);
int length = hello.length();
Thread.sleep(10);
for (int i = 0; i < length; i++)
System.out.print("\b");