Java.util.Locale.getCountry() 方法
描述
java.util.Locale.getCountry() 方法返回此语言环境的国家/地区代码,可以是空字符串或大写的 ISO 3166 2 字母代码。
声明
以下是 java.util.Locale.getCountry() 方法的声明
public String getCountry()
参数
NA
返回值
此方法不返回值。
异常
NA
示例
下面的例子展示了 java.util.Locale.getCountry() 方法的使用。
package com.tutorialspoint;
import java.util.*;
public class LocaleDemo {
public static void main(String[] args) {
// create a new locale
Locale locale = new Locale("ENGLISH", "US");
// print this locale
System.out.println("Locale1:" + locale);
// print the country of this locale
System.out.println("Country:" + locale.getCountry());
}
}
让我们编译并运行上面的程序,这将产生以下结果 −
Locale1:english_US Country:US

