Monday, December 29, 2008

Simple type Wrappers

Java uses simple types, such as int and char for performance reasons. These data types are not part of object hierarchy. They are passed by value to methods and cannot be directly passed by reference. Also there is no way for two methods to refer to the same instance of an int. At times, we need to create an object representation for one of these simple types. Java provides classes that correspond to each of the simple types. In essence, these classes encapsulate, or wrap, the simple types within a class. Thus they are commonly referred to as type wrappers.

0 comments: