Next: Reading of numbers of
Up: Unit 04
Previous: Methods that modify variables
In fact, Java already provides so-called wrapper classes for the
primitive data types. Each primitive data type has an associated class, that
typically has the same name as the data type, but starts with a capital letter
(except for int and char, where the name of the wrapper class
is different):
| Primitive data type |
Corresponding wrapper class |
| byte |
Byte |
| short |
Short |
| int |
Integer |
| long |
Long |
| float |
Float |
| double |
Double |
| char |
Character |
| boolean |
Boolean |
- These classes define special static methods that allow us to perform
operations (such as conversions from and to strings) on the corresponding
primitive data types.
- Moreover, they allow us to ``wrap'' values of primitive types into
objects (which is why they are called wrapper classes). We already
discussed the usefulness of this aspect in parameter passing.
Next: Reading of numbers of
Up: Unit 04
Previous: Methods that modify variables