Javatpoint Logo
Javatpoint Logo

Java Locale getCountry() method

The getCountry() method of Java Locale class returns the country/region code for this locale. This code can either be the empty string, an uppercase ISO 3166 2-letter code. If none is defined, this method will return the empty string.

Syntax

Parameter

NA

Return

The getCountry() method returns the country/region code. This method returns empty string if none is defined.

Example 1

Test it Now

Output:

Locale Name: english_IN
Country Name: IN

Example 2

Test it Now

Output:

Locale1 name: german_AU
Locale2 name: spanish_EC
Country Name of locale1: AU
Country Name of locale2: EC

Example 3

Test it Now

Output:

Locale1 name: german_AU
Locale2 name: spanish_EC
Locale3 name: french_BE
Country Name of Locale1: AU
Country Name of Locale2: EC
Country Name of Locale3: BE

Next TopicJava Locales




Help Others, Please Share

facebook twitter pinterest