Console Class in java

In the previous post, we have seen CharArrayWriter class. In this post, we will see the usage of Console class.

In java, Console class is used to read the input provided from console by the user. It can be used to data like text and password. Typed password will not be visible on the console.

Console class Methods:

  1. public String readLine(): Reads a line from console.
  2. public String readLine(String fmt,Object… args): It provides a formatted prompt then reads the single line of text from the console.
  3. public char[] readPassword(): Reads password from console. Password is not visible at console.
  4. public char[] readPassword(String fmt,Object… args): It provides a formatted prompt then reads the password that is not being displayed on the console.

How to create instance of a console class?

Read the text from Console:
Read password from console:
Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum
CharArrayWriter Class in java
Scanner class in java
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

1 Response

  1. August 8, 2015

    […] previous post , we have see Console class in java. In this post, we will see usage of Scanner […]

Leave a Reply

Your email address will not be published. Required fields are marked *