C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

How to use Console class in java?

0 votes
4,146 views
asked May 14, 2014 by sunny Expert (11,410 points)

1 Answer

0 votes
This class is introduce in java 1.6 version. This class is used to read the contents from the keyboard. Console is a available in “io” package.

We can not object of console class directly. It can be created by using console method available in System class.

import java.io.*;

class Read1{

public static void main(String[] args) throws IOException{

Console c = System.console();

String name = c.readLine(“Enter your name:”);

System.out.println(name);

Char[] pwd = c.readPassword(“Enter your password”);

System.out.println(pwd);

            }

}
answered May 14, 2014 by rock Expert (14,990 points)

Related questions

0 votes
1 answer 88 views
+1 vote
1 answer 4,229 views
4,229 views asked May 14, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 28 views
28 views asked May 11, 2014 by rock Expert (14,990 points)
0 votes
1 answer 30 views
30 views asked Feb 5, 2014 by john Guru (27,140 points)
0 votes
1 answer 929 views
929 views asked May 12, 2014 by augustaina Sr Member (4,820 points)
...