Scanner locale() method in Java with Examples
The locale() method of java.util.Scanner class returns this scanner’s locale.
Syntax:
public Locale locale()
Parameters: The function does not accepts any parameter.
Return Value: This function returns this scanner’s locale
Below programs illustrate the above function:
Program 1:
import java.util.*;
public class GFG1 {
public static void main(String[] argv)
throws Exception
{
String s = "Gfg Geeks GeeksForGeeks" ;
Scanner scanner = new Scanner(s);
System.out.println(scanner.locale());
scanner.close();
}
}
|
Program 2:
import java.util.*;
public class GFG1 {
public static void main(String[] argv)
throws Exception
{
String s = "121324" ;
Scanner scanner = new Scanner(s);
System.out.println(scanner.locale());
scanner.close();
}
}
|
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#locale()
Last Updated :
12 Oct, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...