Is there any function in JAVA to clear the output window. like clrscr() in C. Actually I want to clear the Dos screen of java when an key is pressed
switch(a)
case 1:
clrscr();
case 2:
Exit();
Is there any function in JAVA to clear the output window. like clrscr() in C. Actually I want to clear the Dos screen of java when an key is pressed
switch(a)
case 1:
clrscr();
case 2:
Exit();
In Java We Dont have a method to clear the output window like clrscr() in C
There is no built-in way to really control character-based application in Java.
but there are some options like:
System.out.print('\u000C');
or this one:
for (int i=0; i<25; i++)
System.out.println();
Or one liner code is:
System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
char c = '\n';
int length = 25;
char[] chars = new char[length];
Arrays.fill(chars, c);
System.out.print(String.valueOf(chars));
if screen is bigger increase length variable size
No,as we know java is Object oriented.So we can not clear output in java once we run the program. While in C language, program will run step by step means procedure oriented and In Java, we can call any methods using objects.So we cant clear screen once we execute class file rather it is GUI.