I know how boxing is done. For example, when you write Integer a = 4
, Integer.valueOf(int)
is being called. Likewise, can i see the implementation code for unboxing as well?
Update : It is answered in the suggested question.
I know how boxing is done. For example, when you write Integer a = 4
, Integer.valueOf(int)
is being called. Likewise, can i see the implementation code for unboxing as well?
Update : It is answered in the suggested question.
In such cases,intValue()
gets called to get the primitive value.
Integer a= new Integer(4);
int val = a.intValue();
Like the integer, all the wrapper classes have this method to get it's primitive value.