Java.lang.Short.valueOf(short s) 方法
描述
java.lang.Short.valueOf(short s) 方法返回一个 Short 实例,表示指定的 short 值。
声明
以下是 java.lang.Short.valueOf() 方法的声明。
public static Short valueOf(short s)
参数
s − 这是short值。
返回值
此方法返回一个表示 s 的 Short 实例。
异常
NA
示例
下面的例子展示了 java.lang.Short.valueOf() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class ShortDemo {
public static void main(String[] args) {
short shortNum = 100;
// returns Short instance representing given short value
Short ShortValue = Short.valueOf(shortNum);
// displays the short object value
System.out.println("Short object representing the specified short
value = " + ShortValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Short object representing the specified short value = 100

