Java Scanner locale() Method

The locale() method of Java Scanner class is used to get a Locale which the Scanner class is using.

Syntax

Following is the declaration of locale() method:

Parameter

This method does not accept any parameter.

Returns

The locale() method returns this scanner's locale.

Exceptions

NA

Compatibility Version

Java 1.5 and above

Example 1

Output:

Scan string: Hello JavaTpoint! 12 + 13.0 = 25 
Current Locale: en_IN

Example 2

Output:

Enter Your Name: JavaTpoint.com
Name: JavaTpoint.com
Current Locale: en_IN

Example 3

Output:

Locale:en_IN
Diplay name:English (India)
Display country:India