answersLogoWhite

0

// Open a reader from standard in...

final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

try {

// BufferedReader.readLine can throw an IOException, which is a checked exception.

// So we need to catch it.

String str = in.readLine();

// Integer.valueOf throws a NumberFormatException, which is an unchecked exception.

// Note that we don't need to catch this.

int num = Integer.parseInt(str);

} catch (final IOException ex) {

}

User Avatar

Wiki User

14y ago

What else can I help you with?