Is null a Java keyword?

Not according to the Java Language Specification list of keywords. On the other hand, this doesn't compile:

int null = 10;

The rules for identifiers specify that:

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).

I'm not sure what the benefit of making it not-a-keyword is, to be honest.


Not a keyword - the null literal.

an identifier (oops, no it isn't)

Tags:

Java

Null

Keyword