Java.lang.Byte.byteValue() 方法
描述
java.lang.Byte.byteValue() 将这个 Byte 的值作为一个字节返回。
声明
以下是 java.lang.Byte.byteValue() 方法的声明。
public byte byteValue()
覆盖
Number 类中的 byteValue
参数
NA
返回值
该方法返回该对象转换为byte类型后所表示的数值。
异常
NA
示例
下面的例子展示了 lang.Byte.byteValue() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class ByteDemo {
public static void main(String[] args) {
// create a Byte object b
Byte b;
// assign value to b
b = new Byte("100");
// create a byte primitive bt
byte bt;
// assign primitive value of b to bt
bt = b.byteValue();
String str = "Primitive byte value of Byte object " + b + " is " + bt;
// print bt value
System.out.println( str );
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Primitive byte value of Byte object 100 is 100

