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

