how to create an object of Byte - Java Language Basics

Java examples for Language Basics:byte

Description

how to create an object of Byte

Demo Code

 
public class Main {
 
  public static void main(String[] args) {
    //1. Create a Byte object from byte
    byte b = 10;/*from   w ww .j av a 2s.c om*/
    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);
  }
}

Result


Related Tutorials