Java 5: Scanner class

Not covered on the AP exam

The new Scanner class, in java.util, is a more convenient alternative to BufferedReader. Before, if you wanted to read an integer from the user, you would have to write the following.

BufferedReader in = new BufferedReader(System.in);
int n = Integer.parseInt(in.readLine());
Now you can instead write:
Scanner in = new Scanner(System.in);
int n = in.nextInt();

Like anything related to I/O, this isn't on the AP exam. But it is quite a bit more convenient than BufferedReaders, so some textbooks will switch to using it.

(next)