Wrapper Classes wrap the primitive data type into an Object of its Class. The following table lists the wrapper classes corresponding to each primitive type:
| Primitive Data Type | Wrapper Class |
| boolean | Boolean |
| byte | Byte |
| short | Short |
| int | Integer |
| long | Long |
| float | Float |
| double | Double |
| char | Character |
True to their name, wrapper classes, contain a member variable corresponding to the primitive data type. The value in this member variable can be extracted using a method. The name of the method is of the format <primitive_data_type_name>Value(). For example, the class
Boolean contains a method
booleanValue() which returns the value stored in the object. This has become simpler since the introduction of autoboxing feature in Java 5.
No comments:
Post a Comment