CSC108 Lecture #8 - Wrapper Classes


Each primitive type corresponds to a wrapper class.

These classes also contain static methods, some of which you've seen:

They also contain non-static methods that can be used to access the value that you've stored in the wrapper class.
Here is an example for the Double wrapper class:

double d = 25.5
Double dWrap = new Double (d);
double d2 = dWrap.doubleValue();

Now we can better understand how String input is converted to a double:

double d = Double.valueOf(in.readLine()).doubleValue();

[ CSC108 Home | Outline | Announcements | Newsgroup | Assignments | Lectures | Marks | Links ]


U of T IMAGE

© Copyright 2000. All Rights Reserved.