java - Can we change wrapper class into primitive data types? -


this question has answer here:

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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -