Scanner reset() in Java

reset(): This method is available in java.util.Scanner class of Java.

Syntax:

Scanner java.util.Scanner.reset()

This method resets this scanner.

Parameters: NA

Returns: this scanner.

Exceptions: NA

Approach

Java

import java.util.Scanner;

public class Scannerreset {
    public static void main(String[] args) {

        String source = "Hello World";
        Scanner scanner = new Scanner(source);

        System.out.println(scanner.reset());
        scanner.close();
    }
}

Output:

java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\x{2c}][decimal separator=\x{2e}][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\QNaN\E][infinity string=\Q∞\E]


No comments:

Post a Comment