Java Reference
In-Depth Information
FloatingPointLiteral
BooleanLiteral
CharacterLiteral
StringLiteral
NullLiteral
The type of a literal is determined as follows:
• The type of an integer literal (§ 3.10.1 ) that ends with L or l is long 4.2.1 ).
The type of any other integer literal is int 4.2.1 ) .
• The type of a floating-point literal (§ 3.10.2 ) that ends with F or f is float and its
value must be an element of the float value set (§ 4.2.3 ) .
The type of any other floating-point literal is double and its value must be an ele-
ment of the double value set (§ 4.2.3 ).
• The type of a boolean literal (§ 3.10.3 ) is boolean 4.2.5 ) .
• The type of a character literal (§ 3.10.4 ) is char 4.2.1 ).
• The type of a string literal (§ 3.10.5 ) is String 4.3.3 ) .
• The type of the null literal null 3.10.7 ) is the null type (§ 4.1 ) ; its value is the null
reference.
Evaluation of a lexical literal always completes normally.
15.8.2. Class Literals
A class literal is an expression consisting of the name of a class, interface, array, or prim-
itive type, or the pseudo-type void , followed by a ' . ' and the token class .
The type of C .class , where C is the name of a class, interface, or array type (§ 4.3 ) , is
Class< C > .
The type of p .class , where p is the name of a primitive type (§ 4.2 ), is Class< B > , where B is
the type of an expression of type p after boxing conversion (§ 5.1.7 ).
The type of void.class 8.4.5 ) is Class<Void> .
It is a compile-time error if the named type is a type variable (§ 4.4 ) or a parameterized type
4.5 ) or an array whose element type is a type variable or parameterized type.
It is a compile-time error if the named type does not denote a type that is accessible (§ 6.6 )
and in scope (§ 6.3 ) at the point where the class literal appears.
Search WWH ::




Custom Search