10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.1.8 Unboxing Conversion CONVERSIONS AND PROMOTIONS<br />

88<br />

5.1.8 Unboxing Conversion<br />

Unboxing conversion converts values of reference type to corresponding values of<br />

primitive type. Specifically, the following 8 conversion are called the unboxing<br />

conversions:<br />

• From type Boolean to type boolean<br />

• From type Byte to type byte<br />

• From type Character to type char<br />

• From type Short to type short<br />

• From type Integer to type int<br />

• From type Long to type long<br />

• From type Float to type float<br />

• From type Double to type double<br />

At run time, unboxing conversion proceeds as follows:<br />

• If r is a reference of type Boolean, then unboxing conversion converts r into<br />

r.booleanValue()<br />

• If r is a reference of type Byte, then unboxing conversion converts r into<br />

r.byteValue()<br />

• If r is a reference of type Character, then unboxing conversion converts r<br />

into r.charValue()<br />

• If r is a reference of type Short, then unboxing conversion converts r into<br />

r.shortValue()<br />

DRAFT<br />

• If r is a reference of type Integer, then unboxing conversion converts r into<br />

r.intValue()<br />

• If r is a reference of type Long, then unboxing conversion converts r into<br />

r.longValue()<br />

• If r is a reference of type Float, unboxing conversion converts r into<br />

r.floatValue()<br />

• If r is a reference of type Double, then unboxing conversion converts r into<br />

r.doubleValue()<br />

• If r is null, unboxing conversion throws a NullPointerException

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!