15.7.1
Literals
EXPRESSIONS
The second unusual feature avoids a potential grammatical ambiguity in the
expression:
new int[3][3]
which in Java always means a single creation of a multidimensional array, but
which, without appropriate grammatical finesse, might also be interpreted as
meaning the same as:
(new int[3])[3]
This ambiguity is eliminated by splitting the expected definition of
Primary
into
Primary
and
PrimaryNoNewArray
. (This may be compared to the splitting of
Statement
into
Statement
and
StatementNoShortIf
( 14.4) to avoid the dangling
else
problem.)
15.7.1 Literals
A literal ( 3.10) denotes a fixed, unchanging value.
The following production from 3.10 is repeated here for convenience:
Literal:
IntegerLiteral
FloatingPointLiteral
BooleanLiteral
CharacterLiteral
StringLiteral
NullLiteral
The type of a literal is determined as follows:
The type of an integer literal that ends with
L
or
l
is
long
; the type of any
other integer literal is
int
.
The type of a floating point literal that ends with
F
or
f
is
float
; the type of
any other floating point literal is
double
.
The type of a boolean literal is
boolean
.
The type of a character literal is
char
.
The type of a string literal is
String
.
The type of the null literal
null
is the null type; its value is the null reference.
Evaluation of a literal always completes normally.
312
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved