wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes question on identifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question on identifiers" Watch "question on identifiers" New topic
Author

question on identifiers

Nikhil Iyer
Greenhorn

Joined: May 20, 2009
Posts: 4
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Nikhil Iyer
Greenhorn

Joined: May 20, 2009
Posts: 4
Thank you Christophe . The link was helpful.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38818
    
  23
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

    Joined: May 20, 2009
    Posts: 4
    Thank you for the explanation, Campbell.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 38818
        
      23
    You're welcome

    But surely you mean "Christophe and Campbell"?
    Nikhil Iyer
    Greenhorn

    Joined: May 20, 2009
    Posts: 4
    Yes ...Thanks to both of you.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: question on identifiers