AP® Computer Science A glossary

Scanner (file input)

Also called: Scanner

Course: AP® Computer Science A Shows up in: Unit 4: Data Collections

The java.util class that reads data from a file: Scanner(File f) with nextInt, nextDouble, nextBoolean, next, nextLine, hasNext and close.

Appears in the course and exam description (CED): 4.6.A.64.6.A.74.6.A.94.6.A.10

next, nextInt, nextDouble and nextBoolean read one token (text up to whitespace); a token of the wrong type throws an InputMismatchException. nextLine reads the rest of a line. hasNext returns true while there is more to read. Keyboard input is outside the scope of the AP® exam.

Learn it properly, with a checkpoint 4.6 Using Text Files

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure