wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reserved words in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reserved words in Java" Watch "Reserved words in Java" New topic

Reserved words in Java

Rohan Pujari

Joined: Feb 27, 2007
Posts: 24
Is null a reserved word in java?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
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

Joined: Aug 26, 2006
Posts: 4968

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 ]
I agree. Here's the link: http://aspose.com/file-tools
subject: Reserved words in Java
It's not a secret anymore!