Java Program to Clear Console Screen

You are currently viewing Java Program to Clear Console Screen

Java program to clear console screen

// Java program to clear console screen

public class Main {
  public static void main(String[] args) {
    System.out.print("Hello World");

    //Now clear console screen.
    System.out.print("\033[H\033[2J");
    System.out.flush();

    //Now print new message on console.
    System.out.print("Hello India");
  }
}

Output

Hello India

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply