Java Locale getDisplayCountry() Example
Locale class getDisplayCountry() method example. This example shows you how to use getDisplayCountry() method.
Syntax is : public final String getDisplayCountry()
Method returns a name for the locale's country and If possible, the name returned will be localized according to default locale and if the
locale doesn't specify a country, this function returns the empty string.
Here is the code.
/**
* @(#) GetDisplayCountryLocale.java
* A class representing use of method getDisplayCountry() of Locale class
in java.util Package.
* @Version 24-May-2008
* @author Rose India Team
*/
import java.util.*;
class GetDisplayCountryLocale {
public static void main( String args[] ){
/* Create object of Locale class using contructor
Locale(String language, String country) */
Locale obj1 = new Locale("ENGLISH","Us");
Locale obj2 = new Locale("CHIENESE","China");
System.out.println("object obj1 of Locale class is : "+obj1);
System.out.println("object obj2 of Locale class is : "+obj2);
// getDisplayCountry() method call.
String country = obj1.getDisplayCountry();
System.out.println("Country name for object obj1 : " + country);
country = obj2.getDisplayCountry();
System.out.println("Country name for object obj2 : " + country);
}
} |
Output of the program.
object objLocale1 of Locale class is : english_US
object objLocale2 of Locale class is : chienese_CHINA
Country name for object obj1 : United States
Country name for object obj2 : CHINA |
|