That particular example with class X is discussed on page 604 in K & B. The compiler is not confused because the identifiers are used in different contexts, class name, type parameter, and variable identifier.
Joined: Apr 26, 2006
I understand, but forgetting about Generics, is it discussed either in K&B or elsewhere that
Integer Integer = New Integer() is legal?
This seems like something they'd put on the test (though they may not), yet I only realized it was legal by accident.
Originally posted by Kevin Crays: ... This seems like something they'd put on the test...
Yes, you should expect to be tested on what is legal for an identifier.
An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter. An identifier cannot have the same spelling (Unicode character sequence) as a keyword (�3.9), boolean literal (�3.10.3), or the null literal (�3.10.7).