Scanner useLocale() method in Java with Examples
The useLocale() method of java.util.Scanner class sets this scanner’s locale to the specified locale.
public Scanner useLocale(Locale locale)
Parameters: The function accepts a mandatory parameter locale which specifies a string specifying the locale to use.
Return Value: The function returns this modified scanner.
Exceptions: If the radix is less than Character.MIN_RADIX or greater than Character.MAX_RADIX, then an IllegalArgumentException is thrown.
Below programs illustrate the above function:
Scanner String: Geeksforgeeks has Scanner Class Methods Current Lcoale: en_US Changing Locale to ENGLISH Updated Locale: en
Scanner String: Geeksforgeeks 2018 Current Lcoale: en_US Changing Locale to FRENCH Updated Locale: fr
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.