getCountry(): This method is available in java.util.Locale class of Java.
Syntax:
String java.util.Locale.getCountry()
This method returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.
Returns: The country/region code, or the empty string if none is defined.
For Example:
Locale locale = new Locale("fr", "FR")
locale.getCountry() = > It retruns FR.
Approach
Java
import java.util.Locale;public class LocalegetCountry {public static void main(String[] args) {Locale locale = new Locale("fr", "FR");System.out.println(locale.getCountry());}}
Output:
FR
No comments:
Post a Comment