Autoboxing and Unboxing in Java
Hi guys! Welcome you again to brajeshNotes. In today's session , we will talk about what is auto boxing and auto unboxing in java. So lets start without spending too much time 😊
Autoboxing : Process of converting the primitive value into its corresponding wrapper class value is called auto boxing.
For example converting int to Integer class. Java compiler applies auto boxing when a primitive value is :
- Passed as parameter to a method and expect a corresponding wrapper class value.
- Assign to a variable of corresponding wrapper class.
- Passed as parameter to a method and expect a corresponding primitive type value.
- Assign to a variable of corresponding primitive type.
Below table listed the primitive type and there corresponding wrapper classes , which are used by java compiler during autoboxing and unboxing process.
PRIMITIVE
|
WRAPPER
|
boolean
|
Boolean
|
bye
|
Byte
|
char
|
Character
|
float
|
Float
|
int
|
Integer
|
long
|
Long
|
short
|
Short
|
double
|
Double
|
0 comments:
Post a Comment