// This little program reads an integer and prints it out. // If you want floating point input, use Double instead of // Integer (and change intValue to doubleValue). import java.io.*; // don't forget to import the library class IO { public static void main(String args[]) { // Initialize the String variable line String line=""; // Ask for an integer System.out.print("Please enter an integer: "); // Read characters from standard input: BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); try { line = buf.readLine(); } catch(IOException i) { i.printStackTrace(); System.exit(0); } // Conver the characters to an Integer Integer I = new Integer(line); // Convert the Integer to an int int input = I.intValue(); // Print it out System.out.println("You entered " + input); } }