• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reserved Words vs Keywords

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Could anyone tell me where I can find a reference to what are reserved words and what are keywords?
Cheers,
Brian
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These links might help you -
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
http://java.sun.com/docs/books/jls/html/3.doc.html#229308
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great thanks Ajith
 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ajith,
one further question on this topic. Some questions I have seen have asked if a given list are keywords, and it has marked some of my answers as wrong stating that they are reserved words, not keywords.
Out of the list, are only const & goto the only reserved words in the list.
Thx in advance
------------------
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some mock exams considers literals are reserved words, which I think is wrong.
null - is a null literal.
true/false are boolean literals.
These should not be mistaken for reserved words.

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I used the link that Ajith had given and while reading this a doubt came into my mind.Can someone please enlighten me on this.It says:
"These words(i.e Keywords) are reserved--you cannot use any of these words as names in your Java programs. true, false, and null are not keywords but they are reserved words, so you cannot use them as names in your programs either."
Now my doubt is that functionally what is the difference between keywords and reserved words? We can't use either of them as names of identifiers in our programs, that is understood but what is it that distinguishes a keyword from a reserved word?Am I right in thinking that keywords are used by compilers to perform specific actions while compiling codes while it is not so with reserved words.Waiting for someone to confirm.
Thanks
Gazala.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
1. According to the Sun's Java tutorial:
a. reserved words = keywords (including goto and const) + the literals null, true, false
2. According to the Java Language Specification:
a. keywords (include goto and const) are reserved
b. null, true, false are not keywords but literals
Regards,
Sandeep.
 
reply
    Bookmark Topic Watch Topic
  • New Topic