donaricano-btn

Input by Console

- The Java Console class is used to get input from console

- It provides methods to read text and password

- If you read password using console, it will not be displayed to the user


1. Method of Console class

2. Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public static void main(String[]args){
         
        Console c = System.console();
         
        System.out.println("Enter name");
        String n = c.readLine();
         
        System.out.println("Welcome"+n);
         
        char[] ch = c.readPassword();
        String pass = String.valueOf(ch);
         
        System.out.println("Pass"+pass);
         
    }

'Back-End > Java_1' 카테고리의 다른 글

[Java] Aggregation in java  (0) 2016.08.23
[Java] Inheritance in Java  (0) 2016.08.23
[Java] Input by BufferedReader  (0) 2016.08.22
[Java] Input by Scanner  (0) 2016.08.18
[Java] This keyword - to refer current class instance variable  (0) 2016.08.05
블로그 이미지

리딩리드

,