bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Scanner delimiter() Method

Flash cards

Review the key moves

1/4
Core idea

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.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

// ___ a scanner object Scanner myObj = new Scanner("A string to scan");
3Order

Put the learning moves in the order that makes the concept easiest to apply.

Show the delimiter that is currently being used by the scanner:
Definition and Usage
Java Scanner delimiter() Method

❮ 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

Previous

Java Scanner close() Method

Next

Java Scanner findInLine() Method