Is null
is a keyword in Java?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
true and false are also literals. Java trivia: const and goto are keywords.
No. See this for complete list: Java Language Keywords
Not according to the Java Language Specification list of keywords. On the other hand, this doesn't compile:
The rules for identifiers specify that:
I'm not sure what the benefit of making it not-a-keyword is, to be honest.
null
is a literal similar totrue
andfalse
in Java. These are not keywords because these are the values of something. Asnull
is the value of a reference variable,true
is the value of a boolean variable.Not a keyword - the null literal.
an identifier(oops, no it isn't)It represents a special value but it's not a keyword in Java, and it doesn't mean that we can use it as an identifier. It's restricted to be used as an identifier and that is obvious because we cannot have a special value as an identifier because the compiler will treat that word (null) as special value, not as identifier.