Object of Wrapper class contain primitive data type. Or can say that, we wrap a primitive value into a wrapper class object.
Every wrapper class(except Character class) contains two constructers :- one take corresponding primitive data type and other takes a string parameter.
Example
- short s=20909;
- Short ob1=new Short(s);
- String str="20909";
- Short ob2=new Short(str);
- It is Used in collection framework.
- All the wrapper classes are declared final. All the wrapper classes except Boolean and Character are sub classes of an abstract class called Number, Boolean and Character are derived directly from the Object class.
- Wrapper classes are immutable.
Examples of wrapper classes.
//all programs run on netbean 8.0.2