permaculture playing cards*
The moose likes Beginning Java and the fly likes Is null a keyword? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is null a keyword?" Watch "Is null a keyword?" New topic
Author

Is null a keyword?

Rajiv KumarRai
Greenhorn

Joined: Feb 25, 2013
Posts: 4
Is null a keyword?

Thanks in advance to all ranchers
William Cantree
Greenhorn

Joined: Feb 25, 2013
Posts: 4

If by keyword you mean reserved word? Yes.

Here are all of the reserved words in Java: http://java.about.com/od/javasyntax/a/reservedwords.htm

Otherwise, I have no idea with what you mean...
Rajiv KumarRai
Greenhorn

Joined: Feb 25, 2013
Posts: 4
Yes i meant to say that whether null is a reserved word in Java
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Welcome to the Ranch
No, it is not a keyword. It is a reserved word used as a literal. The details are in the Java Language Specification.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
You need to be specific with what you ask. It may appear pedantic, but you are working with programming and the machine will be very pedantic with you.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3003
    
    9
Although I'm usually on the side of the pedants, I'm not sure how it really matters here. It's certainly true that the JLS says null is not a keyword, and that you can't use null as an identifier. They never appear to describe null as "reserved".

More importantly though, is there any useful consequence of this distinction? I mean, if the JLS had just added null, true and false to the list of keywords, and omitted any mention of the null literal or boolean literals (referring instead to the "keyword null" and the "keywords true and false" respectively) would Java behave any differently? I think the answer is no. Perhaps there's some subtle distinction at work here, but so far I can't see what it is.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Agree it would have made no difference if they had called null a keyword. But oddly enough, as you said, it doesn’t actually say null is a reserved word. The Java5 version of the JLS says exactly the same.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is null a keyword?
 
Similar Threads
WA #1.....word association
Null keyword
null
Is null a keyword......
Null Literals