byte byteValue()
描述 (Description)
java.lang.Short.byteValue()方法以字节形式返回此Short的值。
声明 (Declaration)
以下是java.lang.Short.byteValue()方法的声明
public byte byteValue()
参数 (Parameters)
NA
返回值 (Return Value)
转换为byte类型后,此方法返回此对象表示的数值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.Short.byteValue()方法的用法。
package com.iowiki;
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