Java.lang.Integer.shortValue() 方法
描述
java.lang.Integer.shortValue() 方法将此 Integer 的值作为一个短值返回。
声明
以下是 java.lang.Integer.shortValue() 方法的声明。
public short shortValue()
参数
NA
返回值
该方法返回该对象转换为short类型后所表示的数值。
异常
NA
示例
下面的例子展示了 java.lang.Integer.shortValue() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class IntegerDemo {
public static void main(String[] args) {
Integer obj = new Integer(100);
// returns the value of this Integer as a short
short s = obj.shortValue();
System.out.println("Value of s = " + s);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Value of s = 100

