Java Scanner useLocale(Locale) method example

HQ ┬╗ Java Tutorial ┬╗ java.util ┬╗ Scanner ┬╗ useLocale(Locale) method example
Java Scanner useLocale(Locale) method example 2018-02-20T12:53:13+00:00

java.util.Scanner useLocale(Locale locale)

Description :

This java tutorial shows how to use the useLocale(Locale locale) method of Scanner class of java.util package. This method sets the Locale to be used by this Scanner object overriding the default locale.

Method Syntax :

public Scanner useLocale(Locale locale)

Parameter Input :

DataType Parameter Description
Locale locale The locale to be used by this Scanner

Method Returns :

This method simply returns this Scanner object with Locale being set as method parameter.

Compatibility Version :

Requires Java 1.5 and up

Exception :


Discussion :

The Scanner useLocale() method is helpful to set a locale specific setting which affects many elements in primitive matching regular expressions.

Java Code Example :

This java example source code demonstrates the use of useLocale(Locale locale) method of Scanner class. Basically we just set the Locale setting to our scanner class. We have used the static constant Locale.English to set the method argument Locale.

Sample Output :

Running the useLocale(Locale locale) method example source code of Scanner class will give you the following output

java scanner useLocale(locale) method example

java scanner useLocale(locale) method example

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :


Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.