Flash cards
Review the key moves
What is the main idea behind Java Scanner delimiter() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
// ___ a scanner object Scanner myObj = new Scanner("A string to scan");Put the learning moves in the order that makes the concept easiest to apply.
❮ Scanner Methods
Example
Show the delimiter that is currently being used by the scanner:
// Create a scanner object Scanner myObj = new Scanner("A string to scan");
// Find the delimiter System.out.println(myObj.delimiter());
// Close the scanner myObj.close();Definition and Usage
The delimiter() method returns a Pattern object describing the sequence of characters which separates tokens in the data being scanned. The default delimiter is a sequence of whitespace characters, but it can be changed with the useDelimiter() method.
Learn more about the Pattern object in our Java RegEx tutorial .
What is a token?
A token is a sequence of characters separated from other tokens by delimiters.
Syntax
public Pattern delimiter()Technical Details
| Returns: | A Pattern object describing the sequence of characters that the scanner uses as a delimiter. |
|---|
❮ Scanner Methods