AUTO BOXING AND AUTO UNBOXING
In java there is a new concept it's name is AutoBoxing and Auto UnBoxing. we should aware of all concepts so let's get start.
Auto Boxing:The automatic conversion of premtive to Wrapper object ,this automatic conversion is called autoboxing.
Compiler is responsible to this complete conversion ,there is roll of programmer. compiler internally performs conversion operation.
ex: Integer I=10;
In the above example Integer is Wrapper class and I is object and 10 is premtive value,so that compiler automatically convert prentive to wrapper object.
Auto UnBoxing:Automatic conversion of Wrapper object to premtive is nothing but auto unboxing. and similarly compiler is responsible to the automatic conversion.
Ex: Integer I=10;
int i=I;
In the above example Integer is Wrapper class and I is Wrapper class object ,
and we convert wrapper object to premetive .
Example: Follow the important code of the auto boxing and auto unboxing proper example.
class Test
{
public static Integer I=10; //AB
public static void main(String[] args)
{
int i=I; //AUB
m1(i); //AB
}
public static void m1(Integer K )
{
int m=K; //AUb
System.out.println(m);
}
}
OutPut:
10