java valueof_Java Short类valueOf()方法及示例

java valueof

Syntax:

句法:

    public static Short valueOf (short value);
public static Short valueOf (String value);
public static Short valueOf (String value, int radix's);

简短的类valueOf()方法 (Short class valueOf() method)

  • valueOf() method is available in java.lang package.

    valueOf()方法在java.lang包中可用。

  • valueOf(short value) method is used to represent Short object denoted by the given argument (value) is of short type.

    valueOf(short value)方法用于表示由给定参数表示的Short对象(value)是short类型。

  • valueOf(String value) method is used to represent Short object holding the short value denoted by the given argument (value) is of String type.

    valueOf(String value)方法用于表示Short对象,该对象持有由给定参数(值)表示的short值是String类型。

  • valueOf(String value, int radix's) method is used to represent a Short object holding the short value of the given argument (value) in the radix's given by the second argument.

    valueOf(String value,int radix's)方法用于表示一个Short对象,该对象持有第二个参数给定的基数中给定参数(值)的短值。

  • valueOf(short value) method does not throw an exception at the time of returning a Short instance.

    在返回Short实例时, valueOf(short value)方法不会引发异常。

  • Similarly, valueOf(String value), valueOf(String value, int radix's) method may throw a NumberFormatException at the time of returning an instance.

    同样,在返回实例时, valueOf(String value)valueOf(String value,int radix's)方法可能会引发NumberFormatException

    NumberFormatException: In this exception, if String does not contain a parsable number.

    NumberFormatException :在此异常中,如果String不包含可解析的数字。

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

    这些方法是静态方法,也可以使用类名进行访问,而且,如果尝试使用类对象访问这些方法,那么也不会出错。

Parameter(s):

参数:

  • In the first case, short value – represents the value of the short type.

    在第一种情况下, short值 –表示short类型的值。

  • In the second case, String value – represents the value of String type.

    在第二种情况下, 字符串值 –表示字符串类型的值。

  • In the third case, String value, int radix's – In this method first parameter value represents the value of String type in the radix's given by the second parameter.

    在第三种情况下, String值,int radix's –在此方法中,第一个参数值表示第二个参数给定的基数中String类型的值。

Return value:

返回值:

In the first case, the return type of this method is Short – it returns the Short representation of this short argument.

在第一种情况下,此方法的返回类型为Short-它返回此short参数的Short表示形式。

In the second case, the return type of this method is Short – it returns the Short representation of this String argument.

在第二种情况下,此方法的返回类型为Short-它返回此String参数的Short表示形式。

In the third case, the return type of this method is Short – it returns the Short representation of the String argument in the radix's given by the second argument.

在第三种情况下,此方法的返回类型为Short-它以第二个参数给定的基数形式返回String参数的Short表示形式。

Example:

例:

// Java program to demonstrate the example 
// of valueOf() method of Short class
public class ValueOfShortClass {
public static void main(String[] args) {
short s1 = 100;
short s2 = 200;
short s3 = 40;
short s4 = 20;
// Object initialization
Short ob1 = new Short(s1);
Short ob2 = new Short(s2);
Short ob3 = new Short(s3);
// Display ob1,ob2,ob3 values
System.out.println("ob1 :" + ob1);
System.out.println("ob2 :" + ob2);
System.out.println("ob3 :" + ob3);
// It returns Short object holding the value 
// denoted by the given short argument
Short value1 = ob1.valueOf(s3);
// String object initialization for valueOf(String s)
String s = "80";
// It returns Short object holding the value 
// denoted by the given String argument
Short value2 = ob2.valueOf(s);
// It returns Short object holding the value 
// denoted by the given String argument with radix 20
Short value3 = ob3.valueOf(s, s4);
// Display result values
System.out.println("ob1.valueOf(s3): " + value1);
System.out.println("ob2.valueOf(s): " + value2);
System.out.println("ob3.valueOf(s,s4): " + value3);
}
}

Output

输出量

ob1 :100
ob2 :200
ob3 :40
ob1.valueOf(s3): 40
ob2.valueOf(s): 80
ob3.valueOf(s,s4): 160

翻译自: https://www.includehelp.com/java/short-class-valueof-method-with-example.aspx

java valueof

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

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

相关文章

死锁终结者:顺序锁和轮询锁!

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone死锁(Dead Lock)指的是两个或两个以上的运算单元(进程、线程或协程),都在等待…

Nginx For Windows HTTP转发和负载

Nginx For Windows HTTP转发和负载一、需求说明二、配置文件一、需求说明 使用Nginx进行端口转发,并且负载到两台服务器的服务上。 监控本地服务器的 9099 端口,转发并负载到 127.0.0.1:9001 和 127.0.0.1:9002 服务上。(可以选择只转发到一…

Java PushbackReader mark()方法与示例

PushbackReader类mark()方法 (PushbackReader Class mark() method) mark() method is available in java.io package. mark()方法在java.io包中可用。 mark() method is used to mark the current position in this stream and this method throws an exception during the ca…

轮询锁使用时遇到的问题与解决方案!

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone当我们遇到死锁之后,除了可以手动重启程序解决之外,还可以考虑是使用顺序锁和轮询锁,这部分的内容可以…

DHCP 日志分析

DHCP 日志分析 DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一种有效的IP 地址分配手段,现已经被广泛地应用在各种局域网管理。它能动态地向网络中每台计算机分配唯一的IP 地址,并提供安全、可靠、简…

Nginx For Windows Socket 端口转发

Nginx For Windows Socket 端口转发一、需求说明二、配置文件一、需求说明 使用Nginx进行端口转发 Socket 端口通信。 监控本地服务器的 3001 端口,转发到 10.73.60.48:3001 服务器上的 Socket 端口服务。 二、配置文件 完整配置文件如下,测试可用 #…

16 条 yyds 的代码规范

作者 | 涛姐涛哥链接 | cnblogs.com/taojietaoge/p/11575376.html背景:如何更规范化编写Java 代码的重要性想必毋需多言,其中最重要的几点当属提高代码性能、使代码远离Bug、令代码更优雅。一、MyBatis 不要为了多个查询条件而写 1 1当遇到多个查询条件…

linkedhashset_Java LinkedHashSet clear()方法与示例

linkedhashsetLinkedHashSet类的clear()方法 (LinkedHashSet Class clear() method) clear() method is available in java.util package. clear()方法在java.util包中可用。 clear() method is used to clear all of the existing objects in this LinkedHashSet. clear()方法…

C# 导出word文档及批量导出word文档(3)

在初始化WordHelper时,要获取模板的相对路径。获取文档的相对路径多个地方要用到,比如批量导出时要先保存文件到指定路径下,再压缩打包下载,所以专门写了个关于获取文档的相对路径的类。 1 #region 获取文档的相对路径2 pub…

Nginx For Windows 路由配置

Nginx For Windows 路由配置一、路由配置说明二、需求说明三、配置文件一、路由配置说明 使用Nginx进行路由配置。 使用过 SpringCloud 网关的同学都知道,网关可以使用同一IP地址、同一端口号、不同的服务ID,转发不同服务API信息,不会出现跨…

再见收费的 XShell,我改用国产良心工具!

使用或维护Linux系统的都知道,我们日常对服务器的操作,一般都会借助SSH工具远程登录到服务器之后进行操作。常用的SSH工具有不少,比如:Xshell、Putty、SSH Secure Shell Client、secureCRT等等。我使用过其中两种secureCRT和Xshel…

Java IdentityHashMap put()方法与示例

IdentityHashMap类的put()方法 (IdentityHashMap Class put() method) put() method is available in java.util package. put()方法在java.util包中可用。 put() method is used to set the given value element (val_ele) with the given key element (key_ele) when no valu…

全球六大国际域名解析量统计报告(6月25日)

IDC评述网(idcps.com)06月29日报道:根据DailyChanges公布的实时数据显示,在2015年6月25日,全球六大国际域名解析量总量持续攀升至153,246,819个,环比6月16日,净增46,078个,涨幅增大3…

Windows 创建符号链接

一、场景分析 1.环境变量 在Windows系统配置 环境变量 的时候,经常会遇到以下 路径 情况: C:\Program Files C:\Program Files (x86)\Common Files2.异常情况 这种路径中,存在空格字符,在一些程序调用时,可能出现异…

1.3w字,一文详解死锁!

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone死锁(Dead Lock)指的是两个或两个以上的运算单元(进程、线程或协程),都在等待…

Java Dictionary elements()方法与示例

字典类的elements()方法 (Dictionary Class elements() method) elements() method is available in java.util package. elements()方法在java.util包中可用。 elements() method is used to get the elements of an Enumeration in this dictionary. elements()方法用于获取此…

PHP与ThinkPHP读写文件

2019独角兽企业重金招聘Python工程师标准>>> 使用php将数据写入到指定的文件 $str"<?php return".var_export($phiz,true)."?>"; file_put_contents(./Data/phiz.php); 使用php读取指定的文件 …

软件版本号设置规则及示例

一、版本号设置规则 ABC客户端 版本说明书 [版本命名规则] 如&#xff1a;1.0.0.0 位数名称描述情景第一位主版本重大修改&#xff0c;重写或里程碑[里程碑] [重大更新]第二位次版本显著增强、功能变更较多[新增功能] [删减功能]第三位生成号功能变更&#xff0c;局部修正较多…

【图解】透彻Java线程状态转换

大家好&#xff0c;我是阿星&#xff0c;好久不见&#xff0c;欢迎来到Java并发编程系列番外篇线程状态转换&#xff0c;内容通俗易懂&#xff0c;请放心食用。线程状态先来个开场四连问Java线程状态有几个&#xff1f;Java线程状态是如何转换&#xff1f;Java线程状态转换什么…

Java Byte类的hashCode()方法及示例

短类hashCode()方法 (Short class hashCode() method) hashCode() method is available in java.lang package. hashCode()方法在java.lang包中可用。 hashCode() method is used to return hashcode of the Byte object. hashCode()方法用于返回Byte对象的哈希码。 hashCode()…