• 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

java keyword as a legal identifier

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Nathan and Huiying.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic