Wrapper class in Java

– Each of java’s 8 primitive data types has a class dedicated to it. These are known as wrapper class
– They wrap the primitive data type into an object of that class
– Ex- boolean has Boolean, byte has Byte etc
– int is single value container , primitive data type
– Integer iRef = new Integer(i)- it is wrapper class and called and Boxed(constructing object)
– int j=iRef.intValue() – This is Unboxing (Extracting value from object)
– Integer kRef=i; //It is called Autoboxing, no need to write new keyword

Leave a Reply