» » Boxing and unboxing in java

  • 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);
                  }
            }

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu