Java 整数 byteValue() 方法
java 8object oriented programmingprogramming更新于 2025/11/29 14:36:17
byteValue() 方法以字节形式返回此整数的值。
以下是在 Java 中实现 byteValue() 方法的示例 −
示例
public class Main {
public static void main(String[] args) {
Integer val = new Integer(10);
byte res = val.byteValue();
System.out.println("Value = " + res);
}
}
输出
Value = 10
让我们看另一个例子 −
示例
import java.util.*;
public class Main {
public static void main(String[] args) {
Byte b = new Byte("10");
byte res = b.byteValue();
System.out.println("Byte = " + b );
System.out.println("Primitive byte = "+ res);
}
}
输出
Byte = 80 Primitive byte = 80

