Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

I am new to Java. Can somebody tell me what scanner.skip() does.

1 Answer

0 votes
by (13.1k points)

Scanner.skip() skips the input that matches the specified pattern ignoring the delimiters. It uses regex.

Here is an example for this:

Scanner scan=new Scanner(“Hi, how are you?”);

scan.skip(“.*are “);

System.out.println(scan.nextLine());

scan.close();

The output will be: you?

Want to learn Java? Check out the Java course from Intellipaat.

Browse Categories

...