Scanner locale() in Java

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

Syntax:

Locale java.util.Scanner.locale()

This method returns this scanner's locale.

Parameters: NA

Returns: this scanner's locale.

Exceptions: NA

Approach

Java

import java.util.Scanner;

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

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

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

Output:

en_US


No comments:

Post a Comment