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

Legal Identifier  RSS feed

 
Jessica Ngui
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is the following a legal identifier? If not, can I know why?

int e#;


Thanks!
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A legal identifer contains uppercase or lowercase characters, digits, $, or _, and cannot start with a digit. Also you cannot use a reserved word or keyword. You cannot have any spaces in the identifier. Also you cannot use any Java operator.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See Section 3.8 of the Java Language Specification for additional details.
 
Jessica Ngui
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah guys, I read about the rules. I just wanna confirm that it is a legal identifier, right?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it isn't.
 
Jessica Ngui
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okie, I just found out that # is an illegal character in Java.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!