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

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

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

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

相关文章

推荐一款开源数据库设计工具,比PowerDesigner更好用!

最近有个新项目刚过完需求,正式进入数据库表结构设计阶段,公司规定统一用数据建模工具 PowerDesigner。但我并不是太爱用这个工具,因为它的功能实在是太多了,显得很臃肿繁琐,而平时设计表用的也就那么几个功能。这里找…

cocos2d-x lua 学习笔记(1) -- 环境搭建

Cocos2d-x 3.0以上版本的环境搭建和之前的Cocos2d-x 2.0 版差异较大的,同时从Cocos2d-x 3.0项目打包成apk安卓应用文件,搭建安卓环境的步骤有点繁琐,但搭建一次之后,以后就会非常快捷!OK,现在就开始搭建环境吧&#xf…

rotateleft_Java Integer类rotateLeft()方法与示例

rotateleft整数类rotateLeft()方法 (Integer class rotateLeft() method) rotateLeft() method is available in java.lang package. rotationLeft()方法在java.lang包中可用。 rotateLeft() method is used to returns the value generated by rotating the binary 2s complem…

ORACLE删除当前用户下所有的表的方法

1、如果有删除用户的权限,则可以: drop user user_name cascade; 加了cascade就可以把用户连带的数据全部删掉。 删除后再创建该用户。 --创建管理员用户 create user 用户名 identified by 密码 default tablespace space_data(表空间名称…

Socket粘包问题的3种解决方案,最后一种最完美!

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)在 Java 语言中,传统的 Socket 编程分为两种实现方式,这两种实现方式也对应着两种不同的传输层协议…

【万里征程——Windows App开发】控件大集合1

添加控件的方式有多种,大家更喜欢哪一种呢? 1)使用诸如 Blend for Visual Studio 或 Microsoft Visual Studio XAML 设计器的设计工具。 2)在 Visual Studio XAML 编辑器中将控件添加到 XAML 标记中。 3)在代码中添…

Java Collections BinarySearch()方法与示例

集合类binarySearch()方法 (Collections Class binarySearch() method) Syntax: 句法: public static int binarySearch(List l, Type key_ele);public static int binarySearch(List l, Type key_ele, Comparator com);binarySearch() method is available in jav…

从String中移除空白字符的多种方式!?差别竟然这么大!

字符串,是Java中最常用的一个数据类型了。我们在日常开发时候会经常使用字符串做很多的操作。比如字符串的拼接、截断、替换等。这一篇文章,我们介绍一个比较常见又容易被忽略的一个操作,那就是移除字符串中的空格。其实,在Java中…

[JS][jQuery]清空元素html()、innerHTML= 与 empty()的区别 、remove()区别

清空元素html("")、innerHTML"" 与 empty()的区别 一、清空元素的区别 1、错误做法一: $("#test").html("");//该做法会导致内存泄露 2、错误做法二:$("#test")[0].innerHTML"&qu…

Properties文件位置

这种情况下Properties文件放在和‘当前类’同一目录下 <span style"font-size:14px;">Properties p new Properties(); InputStream in 当前类.class.getResourceAsStream("Properties文件名"); p.load(in); </span> 这种情况下Prop…

Java类class isAnnotation()方法及示例

类的类isAnnotation()方法 (Class class isAnnotation() method) isAnnotation() method is available in java.lang package. isAnnotation()方法在java.lang包中可用。 isAnnotation() method is used to check whether this Class object represents the annotation type or…

不要再用main方法测试代码性能了,用这款JDK自带工具

前言作为软件开发人员&#xff0c;我们通常会写一些测试程序用来对比不同算法、不同工具的性能问题。而最常见的做法是写一个main方法&#xff0c;构造模拟场景进行并发测试。如果细心的朋友可能已经发现&#xff0c;每次测试结果误差很大&#xff0c;有时候测试出的结果甚至与…

读书总结:周鸿祎,我的互联网方法论

目录&#xff1a;1、欢迎来到互联网时代2、互联网用户至上3、颠覆式创新4、免费时代5、体验为王6、互联网方法论第一章&#xff1a;互联网时代1、没人能打败趋势&#xff0c;趋势会导致非线性发展。2、信息的流通变快&#xff0c;商家很难利用非对称性赚钱。3、用户的体验最重要…

Java ClassLoader getResources()方法与示例

ClassLoader类的getResources()方法 (ClassLoader Class getResources() method) getResources() method is available in java.lang package. getResources()方法在java.lang包中可用。 getResources() method is used to identify all the resources with the given resource…

Java中Properties类的操作

http://www.cnblogs.com/bakari/p/3562244.html Java中Properties类的操作 知识学而不用&#xff0c;就等于没用&#xff0c;到真正用到的时候还得重新再学。最近在看几款开源模拟器的源码&#xff0c;里面涉及到了很多关于Properties类的引用&#xff0c;由于Java已经好久没用…

复盘线上的一次OOM和性能优化!

来源&#xff1a;r6d.cn/ZazN上周五&#xff0c;发布前一周的服务器小动荡????事情回顾上周五&#xff0c;通过Grafana监控&#xff0c;线上环境突然出现CPU和内存飙升的情况&#xff1a;但是看到网络输入和输入流量都不是很高&#xff0c;所以网站被别人攻击的概率不高&am…

scanf 输入十六进制_在C语言中使用scanf()输入一个十六进制值

scanf 输入十六进制Here, we have to declare an unsigned int variable and input a value in hexadecimal format. 在这里&#xff0c;我们必须声明一个无符号的int变量&#xff0c;并以十六进制格式输入一个值。 To input a value in hexadecimal format – we use "%…

阅读源码的 4 个绝技,我必须分享给你!

为什么要阅读源码&#xff1f;1.在通用型基础技术中提高技术能力在 JAVA 领域中包含 JAVA 集合、Java并发(JUC)等&#xff0c; 它们是项目中使用的高频技术&#xff0c;在各种复杂的场景中选用合适的数据结构、线程并发模型&#xff0c;合理控制锁粒度等都能显著提高应用程序的…

微信公众号开发 ssl connect error

微信获取公众号授权失败 &#xff1a;ssl connect error 本人用的是微擎&#xff0c;也是刚入手&#xff0c;碰到这个问题感觉很棘手。 通过一步步调试发现问题出在curl 认证这里&#xff0c;得到结果错误代码&#xff1a;35&#xff0c;错误信息就是&#xff1a;ssl connect …

struts2的java.lang.NoSuchMethodException异常处理

不久前在学习struts时出现这个错误&#xff0c;在网上搜索了半天&#xff0c;发现答案不一。将其总结如下&#xff0c;以方便大家参考。 1、 你有没有试试看 其它的方法能不能用&#xff0c;要是都是这种情况的话&#xff0c;可能是你的Action类没有继承structs里面的DispatchA…