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,172 views
asked 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 by rock Expert (14,990 points)

Related questions

0 votes
1 answer 90 views
+1 vote
1 answer 4,239 views
4,239 views asked by augustaina Sr Member (4,820 points)
0 votes
1 answer 29 views
29 views asked by rock Expert (14,990 points)
0 votes
1 answer 31 views
0 votes
1 answer 930 views
930 views asked by augustaina Sr Member (4,820 points)
...