Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Java in General
Method to find reserved words
Tom Diamond
Ranch Hand
Posts: 98
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I do not think it exists.
Never heard of.
Anyway to write one should be straightforward.
Jim Yingst
Wanderer
Posts: 18671
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I agree with Omar. The HashSet class seems ideal for this. Here's a
list
of keywords for you.
"I'm not back." - Bill Harding,
Twister
Steve Loughran
Ranch Hand
Posts: 37
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The code to do this is in apache
tomcat
and then in
ant
; it is there to rename
JSP
pages.
public static String[] keywords = { "assert", "abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "extends", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile", "while" };
the code to compare this is simply
for (int i = 0; i < keywords.length; ++i) { if (className.equals(keywords[i])) { className += "%"; break; } }
for performance, a hash table would be better.
-steve
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
java keywords
A Javascript function is said as "Not a function"
Is null a keyword......
Reserved words in Java
keywords
More...