How to clear the screen in the Java
loke clrscr()
command in c.
I am use the command prompt to run the program.
Please put the code:
class Demo
{
public static void main(String[] s)
{
//clear scrren hear
System.out.println("Hello World");
}
}
Also use Runtime class but thats not work pls give the same code to perform this.
Also using this code but not work:
import java.io.*;
class demo
{
public static void main(String[] s)
{
try
{
String os = System.getProperty("os.name");
if (os.contains("Windows"))
{
Runtime.getRuntime().exec("cls");
}
else
{
Runtime.getRuntime().exec("clear");
}
}
catch (Exception exception)
{
}
//clear scrren hear
System.out.println("Hello World");
}
}