How to read a character from keyboard in Java

1 Answer

0 votes
package javaapplication1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);  
        BufferedReader br = new BufferedReader(isr);  
        char ch = (char)br.read();
        System.out.println(ch);
    }
}


/*
run:

a
a

*/

 



answered Jul 5, 2017 by avibootz

Related questions

1 answer 256 views
1 answer 187 views
187 views asked Jun 29, 2017 by avibootz
1 answer 162 views
1 answer 310 views
1 answer 158 views
1 answer 207 views
...