• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Identifiers  RSS feed

 
Ken Chu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new to Java.
Can anybody please tell me why e# is an invalid identifier?
The compiler shows # as an illegal character, but isn't # one of the unicode characters?
Thank you.
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Identifiers must comply with these rules:

* The first character of an identifier must be a letter, an underscore(_), or a dollar sign($).
* The rest of the characters in the identifier can be a letter, underscore, dollar sign, or digit. Note that spaces are NOT allowed in identifiers.
* Identifiers are case-sensitive. This means that age and Age are different identifiers.
* Identifiers cannot match any of Java's reserved words.
 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Der Ken chu
in java or c++ even in c, only special character allowed with identifier are _,$ that why..
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

From Java Language Specification, 3.8 Identifiers...
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 $ character should be used only in mechanically generated source code or, rarely, to access preexisting names on legacy systems.
 
Ken Chu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your answers. I got it now.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!