Java-Boxing and un-boxing


class Boxing {
public static void main (String[] args) {
Integer integer = 10; /*boxing*/
/*boxing of primitive type 10 [int] into class type integer [class Integer]. From jdk 1.5 onwards.
Assigning an int to Integer was not possible in earlier version of jdk.*/
int j = integer + 10; /*un-boxing*/
System.out.println (integer);
System.out.println (j);
}
}

Post a Comment

0 Comments