Java.lang.Short.shortValue() 方法
描述
java.lang.Short.shortValue() 方法将这个 Short 的值作为一个 short 返回。
声明
以下是 java.lang.Short.shortValue() 方法的声明。
public short shortValue()
参数
NA
返回值
该方法返回此对象在转换为short类型后所表示的数值。
异常
NA
示例
下面的例子展示了 java.lang.Short.shortValue() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class ShortDemo {
public static void main(String[] args) {
// create short object and assign value to it
short sval = 50;
Short sobj = new Short(sval);
// returns short value of Short
short shortValue = sobj.shortValue();
// printing short value
System.out.println("short value of given Short is = " + shortValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
short value of given Short is = 50

