I would say they can be used interchangeably. Here's a link.
No, they are not synonymous. It says specifically on the list of keywords on that list that "null" "true" and "false" are "literals." That means they have symantic content; they actually represent a value.
A reserved word is one which can only be used in a pre-specified context.
Keywords control the flow and running of the programming; they are a little like operators in that respect.
All the keywords in Java are reserved words in the respect that they can only be used in the context they are designed for.
Joined: Oct 13, 2005
Quoted by Gavin Tranter:-
So while you use keywords to define your Java code you can NEVER use reserved words.
Yes, you do. You use the reserved words "null" "true" and "false" all the time.
What it means is that the two keywords "const" and "goto" which are in common use in the C and C++ languages were set as keywords when Java was developed. They are not used; the compiler throws an error if they are. The idea was to prevent people using those concepts at all.
[Edit for minor spelling errors] [ March 08, 2007: Message edited by: Campbell Ritchie ]
Joined: Jan 01, 2007
Originally posted by Campbell Ritchie: Quoted by Gavin Tranter:- Yes, you do. You use the reserved words "null" "true" and "false" all the time.
Not wishing to argue, but Sun defines "null" "true" and "false" as literals:
true, false, and null might seem like keywords, but they are actually literals;
In thier list of keywords, Sun do not list "null", "true" or "false" but they do list the reserved words "const" and "goto". Keywords
So now I am more confused then ever, I think i will reread what I need to know about keywords for the SCJP. :S
Joined: Oct 13, 2005
It actually says in the JLS page you quoted ". . . are reserved for use as keywords."
In the sense that "true" "false" and "null" can only be used in the context they were designed for, they are "reserved" although the JLS doesn't say "reserved."
In most languages keywords are reserved words as well; Java is no exception. It says that "const" and "goto" are "reserved" without ever being used. As it says in the JLS page quoted, this is to allow for better error messages.
I think I actually agree completely with the first half of your post I quoted from. And we can go on splitting hairs about what "reserved" means until the cows come home.