java.util.Locale.getCountry() 方法返回国家/地区代码为这个区域设置,这要么是空字符串或大写的ISO3166两字母代码。
声明
以下是java.util.Locale.getCountry()方法的声明
public String getCountry()
参数
-
NA
返回值
此方法不返回任何值。
异常
-
NA
例子
下面的示例演示java.util.Locale.getCountry()方法的用法。
package com.yiibai; 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