Abstract


  • Make Primitive Datatype to be in a subtyping relationship with the object class to fit into the OOP concept
  • Has built-in method to convert current value to other Primitive Datatype or custom datatypes primitive, known as Boxing

Important

Custom datatype objects are immutable (a new object is created when a new value is assigned).

Resource Demanding

Comes with cost of allocating Heap Segment for OOP Object & collecting garbage afterward. Thus, less efficient than Primitive Datatype

Double d = 4 results in compilation error

int cannot be converted to Double, but double d = 4 works because it is a Widening Type Conversion.

Double d = 4.0 also works because it is Auto-boxing.

Object o = 4; works because 4 will be first auto-boxed to an Integer, and Integer is a subtype of Object.

Attention

All the wrapper classes are not in a subtyping relationship that is found with the primitive datatypes, and you can’t inherits from any wrapper classes!