Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Is null a keyword?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is null a keyword?

Thanks in advance to all ranchers
 
Greenhorn
Posts: 4
Firefox Browser Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i meant to say that whether null is a reserved word in Java
 
Marshal
Posts: 71715
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 71715
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Master Rancher
Posts: 3756
49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 71715
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic