console in Java

The java.io.Console class, or Console class for short, was introduced in Java 6 as a more evolved form of the System.in and System.out stream classes. It is now the recommended technique for interacting with and displaying information to the user in a text-based environment.
The Console class is a singleton. It is created automatically for you by the JVM and accessed by calling the System.console() method. 
<b>Console methods</b>
Name | Description
----- | -----
void flush() | Flushes the console and forces any buffered output to be written immediately.
Console format(String fmt, Object... args) | Writes a formatted string to this console's output stream using the specified format string and arguments.
Console printf(String format, Object... args) | A convenience method to write a formatted string to this console's output stream using the specified format string and arguments. 
Reader reader() | Retrieves the unique Reader object associated with this console.
String readLine() | Reads a single line of text from the console.
String readLine​(String fmt, Object... args) | Provides a formatted prompt, then reads a single line of text from the console.
char[] readPassword() | Reads a password or passphrase from the console with echoing disabled
char[] readPassword(String fmt, Object... args) | Provides a formatted prompt, then reads a password or passphrase from the console with echoing disabled. By disabling echoing, the user does not see the text they are typing, meaning that their password is secure if someone happens to be looking at their screen. String values are added to a shared memory pool for performance reasons in Java. This means that if a password that a user typed in were to be returned to the process as a String, it might be available in the String pool long after the user entered it.If the memory in the application is ever dumped to disk, it means that the password could be recovered by a malicious individual after the user has stopped using the application. The advantage of the readPassword() method using a character array should be clear. As soon as the data is read and used, the sensitive password data in the array can be “erased” by writing garbage data to the elements of the array. This would remove the password from memory long before it would be removed by garbage collection if a String value were used.
PrintWriter writer() | Retrieves the unique PrintWriter object associated with this console.