Home
›
Boxing and unboxing in java
Posted by: InstanceOfJava
Posted date:
Dec 12, 2014
/
- The concept of representing the primitive data values in the form of its equivalent and corresponding wrapper class objects is known as "boxing"
Integer x= new Integer(3);
Double d= new Double(1.2);
- package com.instanceofjavaforus;
public class wraperDemo3 {
public static void main(String args[]){
String s1="12";
Integer i=new Integer(s1);
System.out.println(i);
}
}
- The concept of getting back actual primitive data values present inside wrapper class objects into its corresponding primitive data value known as "unboxing"
Integer x= new Integer(3);
int y= x.intValue();
- package com.instanceofjavaforus;
public class wraperDemo3 {
public static void main(String args[]){
String s1="12";
Integer i=new Integer(s1);
int x=i.intValue();
System.out.println(x);
}
}
- The concept of JVM automatically representing the primitive data values in the form of its
equivalent and corresponding wrapper class objects is known as "Autoboxing".
Integer x=3;
Double d= 1.3;
- package com.instanceofjavaforus;
public class wraperDemo3 {
public static void main(String args[]){
Integer x=3;
Double d= 1.3;
System.out.println(x);
System.out.println(d);
}
}
- The concept of getting back actual primitive data values present
inside wrapper class objects into its corresponding primitive data value automatically by JVM
known as "Autounboxing"
Integer x= new Integer(3);
int y= x;
- package com.instanceofjavaforus;
public class wraperDemo3 {
public static void main(String args[]){
Integer x= new Integer(3);
int y= x;
System.out.println(x);
System.out.println(y);
}
}
No comments