本文共 1556 字,大约阅读时间需要 5 分钟。
getCountry() method is available in java.util package.
getCountry()方法在java.util包中可用。
getCountry() method is used to get the country code for this Locale and the code may like the empty string "", or two-letter code (ISO 3166).
getCountry()方法用于获取此语言环境的国家/地区代码,并且该代码可能类似于空字符串“”或两个字母的代码(ISO 3166)。
getCountry() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.
getCountry()方法是一个非静态方法,可通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
getCountry() method does not throw an exception at the time of returning country code.
返回国家代码时, getCountry()方法不会引发异常。
Syntax:
句法:
public String getCountry();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of the method is String, it returns country code of this Locale.
方法的返回类型为String ,它返回此Locale的国家/地区代码。
Example:
例:
// Java program to demonstrate the example // of String getCountry() method of Locale import java.util.*;public class GetCountryOfLocale { public static void main(String[] args) { Locale lo = new Locale("JAPANESE", "JAPAN"); // Display Locale System.out.println("lo: " + lo); // By using getCountry() method is // to return the country code for this // locale lo String lo_country = lo.getCountry(); // Display Locale Country System.out.println("lo.getCountry(): " + lo_country); }}
Output
输出量
lo: japanese_JAPANlo.getCountry(): JAPAN
翻译自:
转载地址:http://bivzd.baihongyu.com/