This site javatpoint is very useful for programming languages like JAVA,PYTHON,C,C++, Data Structures etc.Java learning Concept also provides technical materials , which are related to latest technologies. We provides very easy lectures to our viewers from beginning to advance level.We focus logical content instead of theoretical content.

Monday, 23 July 2018

AUTO BOXING AND AUTO UNBOXING

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


Adbox