THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1

Identifiers can be as long as you like, but use some taste. Identifiers that are too long are hard to use correctly
and actually obscure your code.


7.1.5. Keywords


Language keywords cannot be used as identifiers because they have special meaning within the language. The
following table lists the keywords (keywords marked with a are reserved but currently unused):


abstract continue for new switch

assert default goto package synchronized

boolean do if private this

break double implements protected tHRow

byte else import public tHRows

case enum instanceof return transient

catch extends int short TRy

char final interface static void

class finally long strictfp volatile

const float native super while

Although they appear to be keywords, null, TRue, and false are formally literals, just like the number
12, so they do not appear in the above table. However, you cannot use null, true, or false as identifiers,
just as you cannot use 12 as an identifier. These words can be used as parts of identifiers, as in annulled,
construe, and falsehood.


7.2. Types and Literals


Every expression has a type that determines what values the expression can produce. The type of an
expression is determined by the types of values and variables used within that expression. Types are divided
into the primitive types and the reference types.


The primitive data types are:


boolean either true or false

char 16-bit Unicode UTF-16 code unit (unsigned)

byte 8-bit signed two's-complement integer

short 16-bit signed two's-complement integer

int 32-bit signed two's-complement integer

long 64-bit signed two's-complement integer

float 32-bit IEEE 754 floating-point number
Free download pdf