I have a big question!!!😕How to clear the console screen when running java console app???😮 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have a big question!!!😕How to clear the console screen when running java console app???😮

For example: I have this very, very simple code:class TestClass { public static void main(String[] args) { System.out.println("Hello"); System.out.println("Hi"); }}I want to clear screen and print "Hi". How to do it??? Please tell me!!! Thanks!!!😊😊😊

12th Jul 2016, 3:55 PM
Nguyen Ngoc Long
Nguyen Ngoc Long - avatar
2 Answers
+ 1
If you are running java from the command prompt, maybe you could get away with try { Runtime.getRuntime ().exec ("cls"); } catch (IOException e) {} It would be more reliable to print alot of blank lines to give the impression that the screen is clear. That works anywhere.
12th Jul 2016, 5:14 PM
Gershon Fosu
Gershon Fosu - avatar
0
Ok! I will try it!!! Thanks for your help!!!😊😊😊
13th Jul 2016, 2:06 AM
Nguyen Ngoc Long
Nguyen Ngoc Long - avatar