Scanner Notes
Scanner Notes
Mrs. Tillman
Computer Science
Using the Scanner Class
• Provides methods for reading byte, short, int, long, float,
double, and String data types from the user.
• Scanner is in the java.util package
• Scanner parses (separates) input into sequences of
characters called tokens.
• By default, tokens are separated by standard white space
characters (tab, space, newline, etc.)
Import Statement
You have to import the statement at the top in order to use
Scanner.
import java.util.Scanner;
import java.util.Scanner;
METHOD DESCRIPTION
double nextDouble() Returns the first double in the input line.
Leading and trailing spaces are ignored.