java 方法 示例

区域设置类getDisplayCountry()方法 (Locale Class getDisplayCountry() method)

Syntax:

句法:

    public final String getDisplayCountry();public String getDisplayCountry(Locale lo);

  • getDisplayCountry() method is available in java.util package.

    getDisplayCountry()方法在java.util包中可用。

  • getDisplayCountry() method is used to display the country name for this Locale.

    getDisplayCountry()方法用于显示此语言环境的国家/地区名称。

  • getDisplayCountry(Locale lo) method is used to display the country name for the locale and the displayed name will be localized as per based on the given parameter (lo) when possible.

    getDisplayCountry(Locale lo)方法用于显示语言环境的国家/地区名称,并且在可能的情况下,将根据给定的参数(lo)根据显示的名称进行本地化。

  • These methods may throw an exception at the time of displaying the name of the country.

    这些方法在显示国家/地区名称时可能会引发异常。

    NullPointerException: This exception may throw when the given parameter is null exists.

    NullPointerException :当给定参数为null时,可能引发此异常。

  • These are non-static methods and it is accessible with the class object and if we try to access these methods with the class name then also we will get an error.

    这些是非静态方法,可通过类对象访问,如果尝试使用类名访问这些方法,则也会收到错误消息。

Parameter(s):

参数:

  • In the first case, getDisplayCountry() – It does not accept any parameter.

    在第一种情况下, getDisplayCountry() –它不接受任何参数。

  • In the second case, getDisplayCountry(Locale lo)

    在第二种情况下, getDisplayCountry(Locale lo)

    Locale lo – represents the locale whose localized behavior depends on the displayed name.

    语言环境lo –表示语言环境的本地化行为取决于显示的名称。

Return value:

返回值:

In both the cases, the return type of the method is String,

在这两种情况下,方法的返回类型均为String 。

  • In the first case, it displays the country name for this locale.

    在第一种情况下,它显示此语言环境的国家/地区名称。

  • In the second case, it displays the country name for the locale based on the given parameter.

    在第二种情况下,它将根据给定的参数显示语言环境的国家/地区名称。

Example:

例:

// Java program to demonstrate the example
// of getDisplayCountry() method of Locale
import java.util.*;
public class GetDisplayCountryOfLocale {public static void main(String[] args) {// Instantiates Locale
Locale lo1 = Locale.getDefault();
Locale lo2 = new Locale("JAPANESE", "JAPAN");
// Display Locale
System.out.println("lo1: " + lo1);
System.out.println("lo2: " + lo2);
// By using getDisplayCountry() method is
// to return the country name this locale
String co1 = lo1.getDisplayCountry();
System.out.println("lo1.getDisplayCountry(): " + co1);
// By using getDisplayCountry(locale) method is
// to return the country name this locale will
// be localized by the given locale
String co2 = lo1.getDisplayCountry(lo2);
System.out.println("lo1.getDisplayCountry(lo2): " + co2);
}
}

Output

输出量

lo1: en_US
lo2: japanese_JAPAN
lo1.getDisplayCountry(): United States
lo1.getDisplayCountry(lo2): United States

翻译自: https://www.includehelp.com/java/locale-getdisplaycountry-method-with-example.aspx

java 方法 示例

java 方法 示例_Java语言环境getDisplayCountry()方法与示例相关推荐

  1. java 方法 示例_Java语言环境getDisplayVariant()方法与示例

    java 方法 示例 区域设置类getDisplayVariant()方法 (Locale Class getDisplayVariant() method) Syntax: 句法: public f ...

  2. java 方法 示例_Java语言环境getAvailableLocales()方法与示例

    java 方法 示例 区域设置类getAvailableLocales()方法 (Locale Class getAvailableLocales() method) getAvailableLoca ...

  3. java 方法 示例_Java语言环境getISOLanguages()方法与示例

    java 方法 示例 区域设置类getISOLanguages()方法 (Locale Class getISOLanguages() method) getISOLanguages() method ...

  4. java 方法 示例_Java语言环境getISOCountries()方法与示例

    java 方法 示例 区域设置类getISOCountries()方法 (Locale Class getISOCountries() method) getISOCountries() method ...

  5. java 方法 示例_Java语言环境getVariant()方法与示例

    java 方法 示例 区域设置类getVariant()方法 (Locale Class getVariant() method) getVariant() method is available i ...

  6. java compareto 中文_java中的compareto方法的详细介绍

    一.java中的compareto方法 1.返回参与比较的前后两个字符串的asc码的差值,如果两个字符串首字母不同,则该方法返回首字母的asc码的差值 String a1 = "a" ...

  7. java集合示例_Java集合的addAll()方法和示例

    集合类addAll()方法addAll()方法在java.lang包中可用. addAll()方法用于将所有给定元素(ele)放入给定集合(co). addAll()方法是一个静态方法,可以使用类名进 ...

  8. java parsefloat 误差_Java Float类parseFloat()方法与示例

    Float类parseFloat()方法parseFloat()方法在java.lang包中可用. parseFloat()方法用于返回与给定String表示形式相对应的float值,换句话说,我们可 ...

  9. java getmethod类_Java Class类 getMethod()方法及示例

    Class类getMethod()方法getMethod()方法在java.lang包中可用. getMethod()方法用于返回Method对象,这些对象指示该类的给定公共方法或由此Class对象表 ...

最新文章

  1. 2018年最后几天学什么?给你关注度最高的10篇文章
  2. [软件更新]Adobe Photoshop Elements 8.0.0
  3. AutoEncoder、RBM、DBM、DBN
  4. Spring : Spring定义Bean的两种方式:lt; bean gt;和@Bean
  5. BZOJ1419: Red is good
  6. 进入多个页签_俄罗斯学生落地签如何办理?
  7. 震惊!!!CSS垂直居中竟然有这么多方法~
  8. [Python學習筆記] 使用xlwings 插入註解 (forked 版本)
  9. 读书笔记|智能运维系统落地方案
  10. cad通过钢筋大样生成钢筋明细表插件_常青藤钢筋工具系统
  11. C语言常见编程题及答案40题
  12. storm和vgj vgj_风暴很忙:VGJ.Storm新阵容亮相DAC预选赛
  13. 【mysql】浮点类型
  14. 通用oa系统_点晴:免费OA系统V20,让协同办公无处不在
  15. 计算机硬盘的文件怎么删除文件,如何清理磁盘多余文件 电脑清除多余的空间及文件的图文步骤...
  16. 推荐10款社群运营必备工具
  17. 投资与财报的学习笔记
  18. 安全性设计之-ip白名单设计
  19. 4.网络爬虫—Post请求(实战演示)
  20. MyBatis中小于号“<“的使用

热门文章

  1. logisticregression参数_通俗地说逻辑回归【Logistic regression】算法(二)sklearn逻辑回归实战...
  2. Linux下的LD_PRELOAD环境变量与库打桩
  3. js如何上传大文件到服务器,js将文件上传到远程服务器
  4. c# 替换html注释,C# 替换div标签
  5. python中的常量可以修改吗_深入理解Python变量与常量
  6. linq查询不包含某个值的记录_MySQL行(记录)的详细操作
  7. alter table add column多个字段_ElementUI表格el-table表头固定自适应高度解决方案
  8. wgs84转经纬度_wgs84经纬度转为cgcs2000平面坐标
  9. 获取http地址如何从上面抓取图片_用 Python 自动抓取妹子图
  10. oracle的EMCTL