August 2004
Intermediate to advanced
480 pages
9h 41m
English
You can't call a method on a Java primitive, such as an int or a double. And sometimes that's a problem because you would like to be able to. Sometimes, you need to hold a list of these kinds of values, and you want to use the classes in the Java Collections Framework; the problem here is that none of those data structures, such as ArrayList, Hashtable, or Vector, will hold primitive types. They only hold objects.
So what's a girl to do? Use the wrapper classes that come with the Java API. There is a class in the java.lang package that corresponds to each of the primitive types. Table 11-1 shows these classes.
| WRAPPER | PRIMITIVE |
|---|---|
| Boolean | boolean |
| Byte | byte |
| Short | short |
| Character | char |
| Integer | int |
| Long | long |
| Float ... |
Read now
Unlock full access