The automatic conversion of primitive data types into its equivalent Wrapper type is known as boxing and opposite operation is known as unboxing. This is the new feature of Java 5. So java programmer doesn't need to write the conversion code.
public class AutoboxingAndUnboxing {
public static void main(String[] args) {
int a=100;
Integer n=new Integer(a); // Boxing
System.out.println("BOXING : "+n);
int x = n; // Un boxing
System.out.println("UNBOXING : "+x);
}
}

No comments:
Post a Comment