Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

help  RSS feed

 
francisco mena
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why e# is not a valid identifier if start with letter and the rule say that After the first character can contain any combination
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Please choose a more descriptive name for your topic, as almost everybody seeks for 'help'.

characters from a-z, 0-9 and the underscore '_' are valid identifiers for a variable name (not that it has to start with either a letter or _ though).

You variable contains # and hence is illegal.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
francisco mena wrote:...the rule say that After the first character can contain any combination

Not quite. Section 3.8 of the Java Language Specification (JLS) says...
An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter...

The Java letters include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024)...

The "Java digits" include the ASCII digits 0-9 (\u0030-\u0039).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!