• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java keyword as a legal identifier

 
ashu s
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
huiying li
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
ashu s
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Nathan and Huiying.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic