- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is boxing and unboxing in Java?
Wrapper classes are those whose objects wraps a primitive data type within them. In the java.lang package java provides a separate class for each of the primitive data type namely Byte, Character, Double, Integer, Float, Long, Short.
Converting primitive datatype to object is called boxing.
Example
Integer obj = new Integer ("2526");
Whereas, converting an object into corresponding primitive datatype is known as unboxing.
Example
public class Sample { public static void main (String args[]){ Integer obj = new Integer("2526"); int i = obj.intValue(); System.out.println(i); } }
Output
2526
Advertisements