java 方法 示例_Java语言环境getDisplayCountry()方法与示例

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541866.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

格力电器Java面试题_JAVA设计模式学习--工厂模式

今天谈一下对工厂模式学习的总结。看完视频和文章之后要自己表述工厂模式,总是感觉无从说起,不知道怎么去定义工厂模式,反复看了几遍之后终于理解一点。自己理解工厂模式是通过这两种模式的特点来理解和定义的,首先工厂模式有简单…

为什么玩我的世界老提示Java se错误_我的世界error错误信息 error could解决方法

我的世界是一个及其开放的沙盒游戏,而在这个游戏中有不少的问题,比如说遇到error该如何解决呢,看小编给大家带来的我的世界error错误的解决方法,希望大家喜欢。error应用程序错误信息。包括“Error:Unable to access jarfile mcpc…

Tomcat 服务器只能存有一个正在运行的项目

即使新建了一个new project (在同一个工作空间),启动Tomcat 还是会出现先前(工程名)一样的问题/异常。 【原因】: 在底下Server 那里——Tomcat 7.X 底下会有很多工程名,它会纪录!所…

Java Collections singletonMap()方法与示例

集合类singletonMap()方法 (Collections Class singletonMap() method) singletonMap() method is available in java.util package. singletonMap()方法在java.util包中可用。 singletonMap() method is used to return an immutable map (i.e. immutable map is a map that c…

java访问登录网页_===java怎样访问需要登录才能查看的网页????急!!===...

java中可以用java.net包下的东西访问网页,但是有的网页要求用户先输入用户名和密码才能查看,这些网页java怎么访问呢???注意:我说的要输入用户名和密码不是浏览器弹出一个框的那种,而是象csdn这…

javascript OOP(下)(九)

一、javascript模拟重载 java中根据参数类型和数量的区别来实现重载&#xff0c;javascript弱类型&#xff0c;没有直接的机制实现重载&#xff0c;javascript中参数类型不确定和参数个数任意&#xff0c;通过判断实际传入的参数的个数来实现重载。 <script> function Pe…

java calendar_Java Calendar getDisplayNames()方法与示例

java calendar日历类的getDisplayNames()方法 (Calendar Class getDisplayNames() method) getDisplayNames() method is available in java.util package. getDisplayNames()方法在java.util包中可用。 getDisplayNames() method is used to return Map that contains all fie…

Linux如何查找大文件或目录总结

转载&#xff1a;http://www.cnblogs.com/kerrycode/p/4391859.html 在Windows系统中&#xff0c;我们可以使用TreeSize工具查找一些大文件或文件夹&#xff0c;非常的方便高效&#xff0c;在Linux系统中&#xff0c;如何去搜索一些比较大的文件呢&#xff1f;下面我整理了一下…

java编写简单邮件_Javamail,编写简单的程序发送邮件

代码&#xff1a;package com.dai.mail; import java.util.Properties; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.In…

java calendar_Java Calendar getLeastMaximum()方法与示例

java calendarCalendar类的getLeastMaximum()方法 (Calendar Class getLeastMaximum() method) getLeastMaximum() method is available in java.util package. getLeastMaximum()方法在java.util包中可用。 getLeastMaximum() method is used to get the least maximum value …

Shell 标准输入、输出和错误

防伪码&#xff1a;桃花潭水深千尺&#xff0c;不及汪伦送我情。文件描述符&#xff08;fd&#xff09;&#xff1a;文件描述符是一个非负整数&#xff0c;在打开现存文件或新建文件时&#xff0c;内核会返回一个文件描述符&#xff0c;读写文件也需要使用文件描述符来访问文件…

java需要会的工具_Java开发者必备的几款工具,一定要掌握!

原标题&#xff1a;Java开发者必备的几款工具&#xff0c;一定要掌握&#xff01;NotepadNotepad是用于编辑xml、脚本以及记笔记的最佳工具。这个工具的最好部分在于&#xff0c;你在Notepad上打开的任何一个文档&#xff0c;在关闭后都会有一个残留文档&#xff0c;它有助于在…

java的equals方法_Java LocalDateTime类| 带示例的equals()方法

java的equals方法LocalDateTime类equals()方法 (LocalDateTime Class equals() method) equals() method is available in java.time package. equals()方法在java.time包中可用。 equals() method is used to check whether this date-time and the given object are equal or…

portlet java_Java Portlet 规范概述

前言1、portlet是一种类似servlet的规范。2、servlet是web组件&#xff0c;portlet也是web组件。参考1、百度百科&#xff1a;portlethttp://baike.baidu.com/link?urlvMzVwpkf5WzOL23GLkgM4C5C7Sarqh1XXShS73L7k-MbGgM0ooZ4Dl2Efor3bb4tZmmLo6v-muG5UW7_CYMTUahttp://hintcnu…

Java LocalDate类| minusWeeks()方法与示例

LocalDate类minusWeeks()方法 (LocalDate Class minusWeeks() method) minusWeeks() method is available in java.time package. minusWeeks()方法在java.time包中可用。 minusWeeks() method is used to subtract the given weeks from this LocalDate and return the LocalD…

Android推荐的几本书

2019独角兽企业重金招聘Python工程师标准>>> 第一阶段 <<第一行代码Android>><<疯狂Android>>第二阶段 <<Android开发艺术探索>><<Android群英传>>Android源码 第三阶段 <<Android开发艺术探索>><&…

java数据类型后缀_java基础知识---基本数据类型

1)四种整数类型(byte、short、int、long)&#xff1a;byte&#xff1a;8 位&#xff0c;用于表示最小数据单位&#xff0c;如文件中数据&#xff0c;-128~127short&#xff1a;16 位&#xff0c;很少用&#xff0c;-32768 ~ 32767int&#xff1a;32 位、最常用&#xff0c;-2^3…

duration java_Java Duration类| minusMillis()方法与示例

duration java持续时间类minusMillis()方法 (Duration Class minusMillis() method) minusMillis() method is available in java.time package. minusMillis()方法在java.time包中可用。 minusMillis() method is used to subtract the given duration in milliseconds from t…

Thread 和 Runnable创建新线程的区别,Runnable可以共享线程类的实例属性

Thread实现多线程&#xff1a; public class Thread2 extends Thread{ public int i; public void run(){ for(; i < 100 ;i) { System.out.println(getName() " " i); } } public static void main(String[] args){ for (int j 0; j < 100; j) { System…

java编程求最小公约数_java求最大公约数与最小公倍数

public class Gongyueshu{public static void main(String[] args){//从控制台输入两个数据int m Integer.parseInt(args[0]);int n Integer.parseInt(args[1]);int y 1 ;int b 1;if (m > 0 && n >0){//先判定这两个数是否为倍数关系&#xff0c;如果是则小数…