集册 Java实例教程 如何创建字节对象

如何创建字节对象

欢马劈雪     最近更新时间:2020-01-02 10:19:05

575
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
如何创建字节对象
 

public class Main {

 

  public static void main(String[] args) {
  /* from 
  时 代 J a v a 公 众 号 - nowjava.com*/

    //1. Create a Byte object from byte

    byte b = 10;

    Byte bObj1 = new Byte(b);

   

    /*2. Create Byte object from String.*/

    Byte bObj2 = new Byte("4");

   

    //print value of Byte objects

    System.out.println(bObj1);

    System.out.println(bObj2);

  }

}