This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java keyword  as a legal identifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java keyword  as a legal identifier" Watch "java keyword  as a legal identifier" New topic
Author

java keyword as a legal identifier

ashu s
Greenhorn

Joined: Feb 12, 2001
Posts: 8
Can java keywords consider as alegal identifier?
consider this e.g.
a. number
b. 12color
c. abstract
can somebody tell me where abstract is legal keyword or not?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

ashu,
a. number is the only legal identifier in your list...
b. 12color starts with a number (which Java begins parsing as a numeric literal), so it is not a legal identifier.
c. abstract is a reserved word (as in public abstract class someClass), so it is not a legal identifier either.
Legal identifiers can consist of upper and lower case characters, numerals, the dollar sign($) and underline(_), and can start with an upper or lower case character, a dollar sign($) or an underline(_), as long as the name of the identifier is not the same as a reserved word.
HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
huiying li
Ranch Hand

Joined: Feb 12, 2001
Posts: 68
Originally posted by ashu s:
Can java keywords consider as alegal identifier?
consider this e.g.
a. number
b. 12color
c. abstract
can somebody tell me where abstract is legal keyword or not?

Here is a useful link:
http://www.cs.umb.edu/java/keywords/

SCJP
ashu s
Greenhorn

Joined: Feb 12, 2001
Posts: 8
Thank you very much Nathan and Huiying.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java keyword as a legal identifier
 
Similar Threads
Why a legal identifier cannot include the character #
assert a Keyword?
Is true is a java legal identifier
Java Abstraction
Is this a legal identifier?