1// in JDK 11 you can do:
2
3// It can be better than exec("cls") because it even works in intellij.
4// Also, putting println() in a for loop is worse because there is a
5// noticable delay between calls. This code does a single call, but
6// stacks a ton of '\n's.
7
8private void clearConsole() {
9 System.out.println(System.lineSeparator().repeat(100));
10}
1public static void clearScreen() {
2 System.out.print("\033[H\033[2J");
3 System.out.flush();
4 }