1 min read

To make java fully object-oriented, wrapper Class was introduced.
It is used to convert a primitive data type into anobject and vice versa.

A wrapper class is divided into two categories:

  • Autoboxing,that converts primitive data type to object.
  • Unboxing, that converts object to primitive data type.


Eight classes of java.lang package are known as wrapper class in java.

Primitive typeWrapper class
boolean Boolean
charCharacter
byte Byte
shortShort
int Integer
longLong
float Float
doubleDouble

Example:-

 class wrapper
 {
 public static void main(String[] args)
 {
 int i=10;
 //Autoboxing
 Integer a=Integer.valueof(i);
 //Integer a=i;   JVM will internally add "Integer.valueof(i);
//Unboxing
 Integer x=new Integer(10);//object of wrapper class
 int y=x.intvalue();
 }
 }

Categories: Uncategorized

Vinay007

I am a loving person with helping nature.Quite introvert but love to express myself to loved ones.Big fan of Army and Mahadev ,yeah I am religious , interested in spirituality and yoga is the ultimate goal.I like to explore new places ,love to ride on adventures ,want to live in every moment and feel every second of life.

0 Comments

Leave a Reply