Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on identifiers

 
Nikhil Iyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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 ?

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Nikhil Iyer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Christophe . The link was helpful.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • 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.
     
    Nikhil Iyer
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for the explanation, Campbell.
     
    Campbell Ritchie
    Sheriff
    Posts: 48652
    56
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You're welcome

    But surely you mean "Christophe and Campbell"?
     
    Nikhil Iyer
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes ...Thanks to both of you.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic