Wrapper classes

Edit on Github instead

Each of Java's primatives data types – int, double, and boolean – can be "wrapped" in a class and become an object.

In general, wrapping a primitive looks like:

<WrapperClassName> <variableName> = new <WrapperClassName>(<primative>);

and in practice, it looks like:

Double d = new Double(3.45);
Integer i = new Integer(4);
Boolean b = new Boolean(false);

There's wrapper classes for each type of primative:

primitive Wrapper class
boolean Boolean
int Integer
double Double
char Character

Suggest changes

Related links

URL Topic Source