Screen clipping taken: 26-01-2024 20:35
Screen clipping taken: 26-01-2024 20:33
Screen clipping taken: 26-01-2024 20:39
Screen clipping taken: 26-01-2024 20:40
Screen clipping taken: 26-01-2024 20:39
Screen clipping taken: 26-01-2024 20:42
The automatic conversion of wrapper type into its
corresponding primitive type is known as unboxing. It is the
reverse process of autoboxing.
The automatic conversion of primitive data type into its corresponding wrapper class is known as
autoboxing, for example, byte to Byte
The wrapper class in Java provides the mechanism to convert primitive into
object and object into primitive.
1 public class WrapperExample2{
Screen clipping taken: 26-01-2024 20:49 2 public static void main(String args[]){
3 //Converting Integer to int
4 Integer a=new Integer(3);
5 int i=a.intValue();//converting Integer to int explicitly
1 public class WrapperExample1{ 6 int j=a;//unboxing, now compiler will write a.intValue() internally
2 public static void main(String args[]){ 7
3 //Converting int into Integer 8 System.out.println(a+" "+i+" "+j);
4 int a=20; 9 }}
5 Integer i=Integer.valueOf(a);//converting int into Integer explicitly
6 Integer j=a;//autoboxing, now compiler will write Integer.valueOf(a) internally
7
Java Page 5