File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reserved words in Java

 
Rohan Pujari
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is null a reserved word in java?
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically null is the null literal.

But like the reserved words, you can't use it as an identifier.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
null is a literal

There's also a special null literal that can be used as a value for any reference type. null may be assigned to any variable, except variables of primitive types. There's little you can do with a null value beyond testing for its presence. Therefore, null is often used in programs as a marker to indicate that some object is unavailable.

Sun Java Tutorial on Primitive Types, Referencing the null Literal

Also interesting is the reference page on keywords:

Here's a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.


Java Language Keywords

Next question: Is there a difference between keywords and reserved words? const and goto are reserved words, but they are not keywords. But are all keywords reserved words? Hmmmm. Makes you think.

Plenty of opinions on the issue, but I haven't seen a definitive definition from Sun.


-Cameron McKenzie
[ March 28, 2007: Message edited by: Cameron W. McKenzie ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic