java - Can we change wrapper class into primitive data types? -
this question has answer here:
- unboxing long in java 8 answers
can change wrapper primitive ?if not happening in code
int = integer.valueof(46); system.out.println(i);
i not getting error.
yes, called unboxing:
integer boxed = 10; // boxing int unboxed = boxed; // unboxing
boxing conversions described in jls 5.1.7; unboxing conversions described in jls 5.1.8.
note if try unbox null
reference, nullpointerexception
thrown:
integer boxed = null; int unboxed = boxed; // npe
Comments
Post a Comment