Why is the identifier e# not a legal identifier for java compiler? The rules for valid identifier given in K&B book are:
----------------------------------------------------------
1. Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ ). Identifiers cannot start with a number!
2. After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.
3. In practice, there is no limit to the number of characters an identifier can contain.
4. You can't use a Java keyword as an identifier. Table 1-1 lists all of the Java keywords including one new one for 5.0, enum.
5. Identifiers in Java are case-sensitive; foo and FOO are two different identifiers.
----------------------------------------------------------
Accordingly the identifer e# doesn't come in any of the above 5 category.
So, why is it not a legal identifier?
Replies:
1. I guess they forgot to add that any special characters other than the currency symbols are not allowed.
2. The # is not a letter! By letter we should consider A to z, I guess...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment