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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TYPES, VALUES, AND VARIABLES Integral Types and Values 4.2.1<br />

4.2 Primitive Types and Values<br />

A primitive type is predefined by the <strong>Java</strong> programming language and named by<br />

its reserved keyword (§3.9):<br />

PrimitiveType:<br />

NumericType<br />

boolean<br />

NumericType:<br />

IntegralType<br />

FloatingPointType<br />

IntegralType: one of<br />

byte short int long char<br />

FloatingPointType: one of<br />

float double<br />

Primitive values do not share state with other primitive values. A variable<br />

whose type is a primitive type always holds a primitive value of that same type.<br />

<strong>The</strong> value of a variable of primitive type can be changed only by assignment operations<br />

on that variable (including increment (§15.14.2, §15.15.1) and decrement<br />

(§15.14.3, §15.15.2) operators).<br />

<strong>The</strong> numeric types are the integral types and the floating-point types.<br />

<strong>The</strong> integral types are byte, short, int, and long, whose values are 8-bit,<br />

16-bit, 32-bit and 64-bit signed two’s-complement integers, respectively, and<br />

char, whose values are 16-bit unsigned integers representing UTF-16 code units<br />

(§3.1).<br />

<strong>The</strong> floating-point types are float, whose values include the 32-bit IEEE 754<br />

floating-point numbers, and double, whose values include the 64-bit IEEE 754<br />

floating-point numbers.<br />

<strong>The</strong> boolean type has exactly two values: true and false.<br />

DRAFT<br />

4.2.1 Integral Types and Values<br />

<strong>The</strong> values of the integral types are integers in the following ranges:<br />

• For byte, from –128 to 127, inclusive<br />

• For short, from –32768 to 32767, inclusive<br />

• For int, from –2147483648 to 2147483647, inclusive<br />

• For long, from –9223372036854775808 to 9223372036854775807, inclusive<br />

35

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

Saved successfully!

Ooh no, something went wrong!