Java.lang.Byte.valueOf() 方法


Java.lang.Byte.valueOf() 方法

package com.codingdict;



import java.lang.*;



public class ByteDemo {



   public static void main(String[] args) {



      // create a byte primitive bt and asign value

      byte bt = -20;



      // create a Byte object b

      Byte b;



      /**

       *  static method is called using class name.

       *  assign Byte instance value of bt to b

       */

      b = Byte.valueOf(bt);



      String str = "Byte value of byte primitive " + bt + " is " + b;



      // print b value

      System.out.println( str );

   }

}