java 方法 示例

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

Syntax:

句法:

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

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

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

  • getDisplayVariant() method is used to display name for the locale variant and the displayed name will be localized as per based on the default locale.

    getDisplayVariant()方法用于显示语言环境变体的名称,并且将根据默认语言环境对显示的名称进行本地化。

  • getDisplayVariant(Locale lo) method is used to display name for the locale variant and the displayed name will be localized as per based on the given locale (lo).

    getDisplayVariant(Locale lo)方法用于显示语言环境变体的名称,并且显示的名称将根据给定的语言环境(lo)进行本地化。

  • These methods may throw an exception at the time of displaying a variant of the locale.

    这些方法在显示语言环境的变体时可能会引发异常。

    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, getDisplayVariant() – It does not accept any parameter.

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

  • In the second case, getDisplayVariant(Locale lo)

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

    Locale lo – represents the locale.

    语言环境lo –表示语言环境。

Return value:

返回值:

In both the cases, the return type of the method is String – it displays variant for the locale but does not return any value.

在这两种情况下,方法的返回类型均为String -它显示语言环境的变体,但不返回任何值。

Example:

例:

// Java program to demonstrate the example
// of getDisplayVariant() method of Locale
import java.util.*;
public class GetDisplayVariantOfLocale {public static void main(String[] args) {// Instantiates Locale
Locale lo1 = new Locale("JAPANESE", "JAPAN", "JAP");
Locale lo2 = new Locale("FRENCH", "FRANCE", "FRA");
// Display Locale
System.out.println("lo1: " + lo1);
System.out.println("lo2: " + lo2);
// By using getDisplayVariant() method is
// to return the name for this locale variant
String var1 = lo1.getDisplayVariant();
System.out.println("lo1.getDisplayVariant(): " + var1);
// By using getDisplayVariant(locale) method is
// to return the name for this locale variant will
// be localized by the given locale
String var2 = lo1.getDisplayVariant(lo2);
System.out.println("lo1.getDisplayVariant(lo2): " + var2);
}
}

Output

输出量

lo1: japanese_JAPAN_JAP
lo2: french_FRANCE_FRA
lo1.getDisplayVariant(): JAP
lo1.getDisplayVariant(lo2): JAP

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

java 方法 示例

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

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

    java 方法 示例 区域设置类getDisplayCountry()方法 (Locale Class getDisplayCountry() 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. 清华大学计算机系教授:马少平——计算机是如何实现智能的(附直播回放)...
  2. 为什么在系统中使用JSON
  3. 2021年高考,26地公布高考出分时间
  4. HttpServlet类简介和简单用法
  5. 运营体系_用户运营系统论:解构复杂产品的大规模用户运营体系
  6. python通过封装可以实现代码复用_Python学习笔记(五)函数和代码复用
  7. activiti 多租户_Activiti中具有独立数据库架构的多租户
  8. android变量要不要附空值,android-如何在使用Parcelable时序列化空值
  9. SharePoint 大局观(4)——从开发人员角度
  10. mysql从服务器配置_mysql主从服务器配置基础教程
  11. 动态加载子节点_省市区递归嵌套子流程动态选择实现
  12. R语言中if语句使用方法之超详细教程
  13. phphstudy运行不了网站_【SEO优化】企业网站进行SEO优化优那些小技巧
  14. 运维自动化之使用PHP+MYSQL+SHELL打造私有监控系统
  15. 属牛的女宝宝取名:聪明上进、清秀纯真的女孩名字
  16. TeamViewer 如何注册账户?
  17. 解决VMware安装ubuntu16.04后无法全屏的问题
  18. poco 连接mysql_[Poco]数据库操作简介
  19. 微信公众号的黑色商业链揭秘
  20. 瑞典皇家理工学院计算机学什么,瑞典皇家理工大学学科设置是怎样的?

热门文章

  1. atomikosdatasourcebean mysql_SpringBoot2整合JTA组件实现多数据源事务管理
  2. Linux基础(文件权限续篇)
  3. python调用窗口找到文件,使用Python在Mac OS X中查找当前活动窗口
  4. 控制台:Unable to import maven project: See logs for details日志:Unable to create injector, see the follow
  5. JDK源码解析之 java.lang.Integer
  6. Docker+Nginx部署Angular国际化i18n
  7. 为什么我不用ViewPager或RecyclerView来做上下滑切换
  8. 零基础入门深度学习(5) - 循环神经网络
  9. 饶军:Apache Kafka的过去,现在,和未来
  10. CentOS7:JDK1.7.0_80安装