Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IMP!- can, boolean literals (true, etc),unused reserved words,BE CALLED Keywords ?

 
sarim raza
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
examples include;
boolean literals: true false null
unused reserved :goto const cast byvalue outer inner operator generic future rest var

ARE THESE KEYWORDS, CAN THEY BE CALLED KEYWORDS ???
 
Warren Bell
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
true and false are keywords True and False are not.
public class True // Will compile and print 11
{
public static void main(String[] args)
{
int True = 11;
System.out.println(True);
}
}
public class True // Will not compile
{
public static void main(String[] args)
{
int true = 11;
System.out.println(true);
}
}
------------------
Warren Bell
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarim,
JLS §3.9 describes const and goto as being reserved as keywords.
true and false are boolean literals; they are not keywords BUT cannot be used as identifiers. The same goes for null which is also a literal.
The other words you listed are not keywords. Nor have I come across any mention of their being reserved. Try using them as identifier names; if the code compiles, they're not reserved.
Hope that helps.
------------------
Jane
The cure for boredom is curiosity.
There is no cure for curiosity.
-- Dorothy Parker
 
Tom Tang
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Jane:
Is there any difference between Java keywords and Java reserved words? I saw at least two books list true and false as java keywords.
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what if they ask the question what r java keywords and give
options
true
null
goto
const
etc shud we select these ?
please answer this question
 
Anand Yadav
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Mathew
In case of questions asked in JCP with the above given options
you should only mark the following ones except ( true & false & null ) they are literals .

goto
const
[This message has been edited by Anand Yadav (edited December 30, 2000).]
[This message has been edited by Anand Yadav (edited December 30, 2000).]
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tom,
When you have any doubts about which words are keywords, check the JLS§3.9. The words listed are the only keywords for Java.
It also explains that goto and const are considered keywords; even though they are not currently used by the language and that true, false, and null are literals, not keywords, but, like keywords, they may not be used as identifiers ie variable, method, etc names.
I have never seen any references to reserved words in the literature although I have seen it used on mocks. For exam purposes ... stick to the definitions given in the JLS.
Hope that helps.
------------------
Jane
The cure for boredom is curiosity.
There is no cure for curiosity.
-- Dorothy Parker
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic