• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is this a legal identifier?  RSS feed

 
Padmalatha Kontham
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int e#;


Is this a legal java identifier? if not why?
 
Srikanth Ramu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# does not come under the permissible identifier part. Check using Character.isJavaIdentifierPart('#') which will return false. For more information refer:

"Naming" section: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/variables.html

"3.8 Identifier" section: http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try it out? It's very easy and you'll have the answer in less than a minute.

The compiler says:

C:\temp>javac Test.java
Test.java:3: illegal character: \35
int e#;
^
1 error
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!