| 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: 14672
|
|
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: 32674
|
|
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 throughoutConstant identifiers (public static final) are UPPER_CASE throughout with words separated by underscoresYou 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: 32674
|
|
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.
|
 |
 |
|
|
subject: question on identifiers
|
|
|