I want to write a program which instantly displays a character when it is typed in console. For example, output asks 'Enter'. Suppose I write char 'g' in console. It should instantly display in console. Also, after entering char, I don't want to press enter. Please explain to me how can I achieve this and also explain the concept.
I have tried this code:
import java.io.*;
public class input {
public static void main(String[] args) throws IOException {
InputStreamReader ir=new InputStreamReader(System.in);
System.out.println(ir.read());
}
}