This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Method to find reserved words  RSS feed

 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there a method in the Java API that indicates wether a string given as parameter is a reserved word or not? (reserved word aka 'public', 'void', etc.).
Tnx,
Tom.
 
omar khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think it exists.
Never heard of.
Anyway to write one should be straightforward.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Omar. The HashSet class seems ideal for this. Here's a list of keywords for you.
 
Steve Loughran
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code to do this is in apache tomcat and then in ant; it is there to rename JSP pages.

the code to compare this is simply

for performance, a hash table would be better.
-steve
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!