Posted by Unknown
Friday, March 13, 2009

In java there is no library package like clearscreen() in c to clear the standard output ,but I introduce here one trick to override the difficulty.This code not actually clear the screen,it overwrite the line printed in one line and start print  again in same line with the help of '\r'  - return

The code of the program is given below:(ClearScreen.java)
public class ClearScreen {

  
    public static void main(String[] args) {
        int i;
        for (i = 0; i <100; i++) {
       
            System.out.print("\r" + i);
            try {
                Thread.sleep(500);

            } catch (InterruptedException ie) {
                System.out.println(ie.getMessage());
            }
        }
    }
}





0 comments