What is Autoboxing and Autounboxing in Java?

What is Autoboxing and Autounboxing in JAVA?


Autoboxing:-  
Autoboxing is automatic conversion of primitive data type to their object equivalents(or boxed primitive).
Autoboxing is converting a primitive value like  "char" into object of  the corresponding  wrapper class  like "Character". as example int into Integer,char into Character,boolean into Boolean etc.

Example:-

int a=10;

Integer b=a;


Unboxing/Autounboxing:-
Unboxing is conversion of object reference into primitive data type.
unboxing is converting object of wrapper class  like"Character" into primitive value as "char". As example Integer into int, Boolean into bolean etc.

Example:-


int c=b;



Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments:

Post a Comment