Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Convert byte primitive to Byte Object example

  1. /*
  2.  * Convert byte primitive to Byte Object example. Program to convert Java
  3.  * byte primitive data type to Byte object.
  4.  */
  5.  
  6. public class BytePrimitiveToByteObject {
  7.  
  8.  public static void main(String args[]){
  9.  
  10.   //new byte primitive
  11.   byte b = 5;
  12.  
  13.   //Use Byte(byte b) constructor
  14.   Byte bObj1 = new Byte(b);
  15.  
  16.   System.out.println("byte converted to Byte: " + bObj1);
  17.  
  18.  }
  19.  
  20. }
No votes yet
Share this

Post new comment

6 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.