java 方法 示例_Java语言环境getDisplayCountry()方法与示例_cumt951045的博客-程序员宅基地

技术标签: python  java  linux  编程语言  人工智能  

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 方法 示例

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cumt951045/article/details/107798992

智能推荐

FreeCAD windows下用CMake编译_freecad cmake-程序员宅基地

最近开始使用FreeCAD这一免费开源的软件进行专业软件的开发。软件网址:https://www.freecadweb.org/官方简介:FreeCAD is a 3D CAD/CAE parametric modeling application. It is primarily made for mechanical design, but also serves all ot..._freecad cmake

error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间 -- 原因可能是参数错误或者自定义函数名和库函数名冲突...-程序员宅基地

今天运行程序的时候遇到了下面这个bug1> B1020.cpp1>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(371): error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间1> e:\vs2013\vs2013_rtm_ult_chs\data\vc...__container': 当后面跟“::”时必须为类或命名空间

在html中怎么让直线有弧度,使用HTML5 Canvas API绘制弧线的教程_nlua的博客-程序员宅基地

绘制标准圆弧在开始之前,我们优化一下我们的作图环境。灵感来自于上节课的纹理,如果不喜欢这个背景,我在images目录下还提供了其他的背景图,供大家选择。另外把所有的样式表都写在了下。JavaScript Code复制内容到剪贴板html>新的画布body{background:url("./images/bg3.jpg")repeat;}#canvas{border:1px..._前端 一条直线怎么变弯

“DNS服务器”–ServiceManager[Binder Server](三)_服务器dns manager在哪-程序员宅基地

上篇文章讲了Binder的驱动,也没有详细的扣源码,一条主线:先在kernel层注册Binder驱动,提供binder_open、binder_mmap、binder_ioctl等接口来操作,根据Binder序言这篇文章中得出来的结论,binder客户端通过驱动先去访问ServiceManager,查询到服务端的地址,客户端再去访问服务端(通过驱动),我们也已经知道ServiceManager是系统中使用binder提供服务通信的大管家(从驱动篇中的命令:BINDER_ SET _ CONTEXT _ MG_服务器dns manager在哪

Mybatis源码学习笔记_sqlsession [org.apache.ibatis.session.defaults.def-程序员宅基地

Mybatis核心概念:Configuration : 管理 mysql-config.xml 全局配置关系类SqlSessionFactory: Session 管理工厂接口 Session: SqlSession 是一个面向用户(程序员)的接口。SqlSession 中提供了很多操作数据库的方法 Executor : 执行器是一个接口(基本执行器、缓存执行器)。 作用..._sqlsession [org.apache.ibatis.session.defaults.defaultsqlsession@796fc0ea] w

Windows笔记本网卡驱动坏了/wifi图标消失_笔记本wifi驱动-程序员宅基地

按下【Win+R】组合键打开运行,输入:services.msc 点击确定打开服务;确保wired aotoconfig 和 Wlan Autoconfig 服务在启动状态为【已启动】 右键开始,点击设备管理器,找到网络适配器 将有感叹号的驱动右键卸载,然后重启。用U盘在另一台电脑上下载对应自己电脑版本的网卡驱动,然后安装重启。我的是Dell笔记本Dell驱动 方法一和方法二都不行的情况下。打开设备管理器,找到有感叹号的驱动,右键属性如果是无线网卡windows仍在设置此设备的类配置,代码56这个问题需要_笔记本wifi驱动

随便推点

五、es6.x版本mapping设置介绍_es6.x mapping-程序员宅基地

Mapping主要类似数据库中表字段定义,主要有如下作用:定义Index下字段名(Field Name)定义字段的类型,比如数值型,字符串型、布尔型等定义倒排索引的相关配置,比如是否索引、记录postion等需要注意的是,在索引中定义太多字段可能会导致索引膨胀,出现内存不足和难以恢复的情况,下面有几个设置:index.mapping.total_fields.limit:一个索引中能定..._es6.x mapping

wireshark 转端口显示_wireshark显示端口-程序员宅基地

现象是这样的:_wireshark显示端口

CSS HTML实现后,却发现与屏幕宽度不一致,超出部分如何解决?-程序员宅基地

div宽度与屏幕的大小不一致,试了很多方法无法解决!咱们这次要实现的是宽度自适应,与屏幕大小一致,可是但整体的内容编程出来后却是”宽度超出很多,如下图:“相信大家都有遇到过这种类似情况,在我上网搜索了解决方法后,仍然不能解决我的超出宽度。(第一种使用:width:auto; overflow:hidden)(第二种使用:宽度:100%;填料;箱上浆:边界框;)下面是我的解决方案,首先使用一个meta标签屏幕的自适应宽度,然后加使用一个大div包裹住,使用CSS样式将屏幕宽度去掉,下面奉上代码图

JUC辅助类&读写锁&阻塞队列_juc 包中锁、阻塞队列-程序员宅基地

JUC辅助类CountDownLatch(减少计数)主线程被阻塞,直到其他线程将计数减到0。代码主线程调用countDownLatch的await方法而被阻塞,等待其他线程将初始计数减到0。package com.atguigu.thread; import java.util.concurrent.CountDownLatch; /** * * @Description: * *让一些线程阻塞直到另一些线程完成一系列操作后才被唤醒。 * * CountDownLatch主_juc 包中锁、阻塞队列

每日一道java笔试题——leetCode:1508. 子数组和排序后的区间和(中等)_非空连续子数组内所有元素之和-程序员宅基地

每日一道java笔试题——leetCode:1508. 子数组和排序后的区间和(中等)给你一个数组 nums ,它包含 n 个正整数。你需要计算所有非空连续子数组的和,并将它们按升序排序,得到一个新的包含 n * (n + 1) / 2 个数字的数组。请你返回在新数组中下标为 left 到 right (下标从 1 开始)的所有数字和(包括左右端点)。由于答案可能很大,请你将它对 10^9 + 7 取模后返回。示例 1:输入:nums = [1,2,3,4], n = 4, left = 1, ri_非空连续子数组内所有元素之和