KnowledgeBoat Logo
|

Computer Applications

What important is automatically happening in following code ?

long a = 124235L; 
Long b = new Long(a);
long c = b.longValue(); 
System.out.println(c);

Java Library Classes

5 Likes

Answer

Long b = new Long(a);

This statement boxes long type a into a Long object b, boxing a primitive type into a Wrapper class object.

long c = b.longValue();

This statement unboxes Long object b and stores it in long variable c, converting a Wrapper class object into a primitive data type.

Answered By

5 Likes


Related Questions