56 How to Represents Primitive Byte data into Wrapper Class Byte Object?

Code:


public class Test
{
public static void main( String args[] )
{
byte b1 = 100;
Byte b2 = new Byte(b1);

System.out.println(" b1: "+b1+" b2: "+b2);
System.out.println(" b2: "+b2.hashCode());

Byte b3 = new Byte(b1);

System.out.println(" b1: "+b1+" b3: "+b3);
System.out.println( b2.equals(b3) );
System.out.println( Byte.BYTES );
System.out.println( Byte.MAX_VALUE );
System.out.println( Byte.MIN_VALUE );

String c1 = "100";
Byte c2 = new Byte(c1);
System.out.println(" c1: "+c1+" c2: "+c2);

System.out.println(b2+b3);
System.out.println(c1+b3);
System.out.println(c2+b3);

}
}


Output:



Previous
Next Post »