// usage: java ReadInt // shows one way of reading an integer typed at the keyboard import java.io.*; public class ReadInt { public static void main(String[] Args) throws IOException { System.out.println("enter an integer, and hit Enter"); // in order to use readLine(), we must wrap System.in in // InputStreamReader, and that in turn in BufferedReader BufferedReader B = new BufferedReader(new InputStreamReader(System.in)); // to simplify, no try/catch here; we just have "throws" above String S = B.readLine(); int N = Integer.parseInt(S); System.out.println("you entered "+N); } }