Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

identifier - currency symbols

 
Moya Green
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are currency symbols treated as valid identifiers? I know identifier beginning with $ is valid. How about others, say foreign currency symbols?
Thanks a lot!
Moya
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may find your answer in JLS 3.8 Identifiers

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.

[ August 19, 2002: Message edited by: Valentin Crettaz ]
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It says that the Java letters include those letters, but not that they are the only Java letters.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the isJavaIdentifierStart and isJavaIdentiferPart method of
java.lang.Character.
 
Moya Green
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for all your help.
So the followings are valid identifiers:
€123, �java, �exam
Please correct me :roll: .
Moya
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Moya Green:
So the followings are valid identifiers:
€123, �java, �exam

Yes
 
Moya Green
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Anthony! I got it.
Moya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic