0

what's wrong in this code? I'm trying to make compiler accept my keyboard input; but compilation is not ending while it's also not throwing any error or warning. I'm using Eclipse 4.14 for Mac OS X. Can anyone suggest.

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

public class TestInputStream {
    public static void main(String args[]) throws IOException {
        InputStreamReader Obj = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(Obj);
        int a = Integer.parseInt(br.readLine());
        System.out.println("Please enter your choice");
        System.out.println("You have entered " + a);
    }
}
Ivar
  • 6,138
  • 12
  • 49
  • 61
  • 6
    This should work just fine, except for the fact that `"Please enter your choice"` will only be printed _after_ your entered a number. – wjans Jan 23 '20 at 13:03
  • Yeah that's Ok, but I'm trying to make this work..it's coming fine with: Scanner br=new Scanner(System.in); System.out.println("Enter number 1: "); int a=br.nextInt(); – Ayan Bose Jan 23 '20 at 19:07

0 Answers0