Wrapper classes are classes for the primitive data types.
We need them because:
We need them because:
- Null can be a possible value
- Would get to write lot of utility methods which can make conversions easier
- Helps in OOP
- Can be used in collection as it is a class
Converting a primitive type to a wrapper class is called Autoboxing.
Converting a wrapper class object instance to a primitive type is called unboxing.
Integer i = 12; // autoboxing
int k = i; //unboxing
No comments:
Post a Comment