Java Locale.toString()
Syntax
Locale.toString() has the following syntax.
public final String toString()
Example
In the following code shows how to use Locale.toString() method.
//from w w w . jav a 2 s. co m
import java.util.Locale;
public class Main {
public static void main(String[] args) {
Locale locale1 = new Locale("en", "US", "WIN");
System.out.println("Locale:" + locale1);
// print the locale as a string
System.out.println("Locale:" + locale1.toString());
Locale locale2 = new Locale("fr", "FRANCE", "WIN");
System.out.println("Locale2:" + locale2);
// print the locale as a string
System.out.println("Locale2:" + locale2.toString());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »