The Runtime class provides mechanism to get the console of the current runtime environment. Using this, we can perform needed actions on the console.
import java.io.*;
public class SystemConsole
{
   public static void main(String args[])
   {
      SystemConsole systemConsole = new SystemConsole();
      systemConsole.proceed();
   }
  Â
   private void proceed()
   {
      System.out.println(“Getting handle of runtime Console”);
      Console runtimeConsole = System.console();
      System.out.println(“Got handle of runtime Console”);
      System.out.println(“You can now use runtimeConsole object to perform actions of your choice on java.io.Console”);
   }
}
/*
Expected output:
[root@mypc]# java SystemConsole
Objects.deepEquals(1,1):Â true
Objects.deepEquals(1,2):Â false
Objects.deepEquals(“abc”,”abc”):Â true
Objects.deepEquals(“aa”,”ab”):Â false
*/
Related Articles
- Automation of Tasks
- How to Increase the Size of an Array in Java
- Get the Abstract Methods of a Class
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.






















