Java.lang.Short.intValue() 方法
描述
java.lang.Short.intValue() 方法将此 Short 的值作为 int 返回。
声明
以下是 java.lang.Short.intValue() 方法的声明。
public int intValue()
参数
NA
返回值
该方法返回该对象转换为int类型后所表示的数值。
异常
NA
示例
下面的例子展示了 java.lang.Short.intValue() 方法的使用。
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 = 30;
Short sobj = new Short(sval);
// returns int value of Short
int intValue = sobj.intValue();
// printing int value
System.out.println("int value of Short is = " + intValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
int value of Short is = 30

