java | boxing unboxing example

//1.Example of Auto-Boxing:the automatic convesion of premetive type to wrapper type
//2.Example of Auto-UnBoxing:the automatic conversion of wrapper type to premitive //type


class Test
{

public static void main(String ar[])
{

int i;//primitive type


//Auto UnBoxing

i =new Integer(5);  //2 Wrapper(or object equivalent) to premitive

System.out.println("i="+i);


//Auto Boxing

Integer objI = i;   // 1.premetive type to Wrapper type(or their object equivalent.)

System.out.println("objI="+objI);

}




}
Reactions:

0 comments:

Post a Comment