• 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

question on identifiers

 
Greenhorn
Posts: 26
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the lesson on java identifiers , i see that the below mentioned identifier is considered illegal , but not sure why ? I mean - it seemed to follow the rules .

int e#_couut;

Is it because '#' is not a unicode character ? Is there a chart some where that lists all the allowed values that can be used in an identifier name ?

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is there a chart some where that lists all the allowed values that can be used in an identifier name ?


Yes, not a chart, but an explanation, here.
 
Namith Kumar
Greenhorn
Posts: 26
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Christophe . The link was helpful.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The convention is that identifiers should begin with a letter (Upper-case for class/interface/enum names, lower-case for everything else) and then contain letters and numbers only. $_ are permitted by the compiler, but should be avoided.
The exceptions are:
  • Package names may contain underscores _ and may begin with underscore (see this Java™ Tutorials section) and are lower-case throughout
  • Constant identifiers (public static final) are UPPER_CASE throughout with words separated by underscores
  • You will see identifiers beginning with $; those names are added automatically by compilers.
     
    Namith Kumar
    Greenhorn
    Posts: 26
    Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you for the explanation, Campbell.
     
    Campbell Ritchie
    Marshal
    Posts: 79178
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You're welcome

    But surely you mean "Christophe and Campbell"?
     
    Namith Kumar
    Greenhorn
    Posts: 26
    Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Yes ...Thanks to both of you.
    reply
      Bookmark Topic Watch Topic
    • New Topic