该byteValue()方法以字节的形式返回此Integer的值。
以下是byteValue()在Java中实现该方法的示例-
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