Hi,

I would like to know the code used for java to clear the screen as we do in c# using Console.clear(); is it possible in Java aswell? If yes, what code should i use?

It isn't possible in Java.

A workaround would be to create 20 or so white lines, or how many you see fit.

As Aviras said, there is no real clear screen in Java. Supposed you are doing it on a console, if you want, you could try...

System.out.println("\u001b[2J");

That should have an effect similar to clear() but not exactly the same.

System.out.println("\u001b[2J");

Could you explain what does it do?
I think it has nothing to clear ...

It doesn't clear the console but it will automatically add new lines to the console until your command line is at the bottom of the console display. Normally, you would see that all of other contents are gone from the display. You may try it?

but it will automatically add new lines to the console until your command line is at the bottom of the console display. Normally, you would see that all of other contents are gone from the display.

Could you make it more clear . I cant understand what you are trying to say.

u001b[2J . What does it do ?

It will be nice if you explain with small program..

Hmm... Just tested on Window box and it seems to not work as I expected... On Linux, it works fine... I am sorry. Need to look further into this thing...