Java 整数 byteValue() 方法


byteValue() 方法将此 Integer 的值返回为一个字节。

以下是 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

更新于: 2019-09-20

171 人已查看

开启您的 职业生涯

完成课程可获得认证

开始
广告
© . All rights reserved.