• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 816
  • Last Modified:

why is int e# an incorrect variable name?

Why is int e# an incorrect variable name? if in the end is a letter followed by a character that well could be a connector character, i mean ,  is not a plus or a minus.
0
bachstein
Asked:
bachstein
  • 2
1 Solution
 
CEHJCommented:
You can test any non-start character with
System.out.println(Character.isJavaIdentifierPart('#'));

Open in new window

0
 
bachsteinAuthor Commented:
Thanks CEHJ, but in  a certification test scenario , my guess would have been, yes it is valid. It turns out is not,  why?. I just have to learn it the way it is?
0
 
CEHJCommented:
iirc only numbers, letters and underscores. The first of these can't start an identifier
0
 
objectsCommented:
simply because # is not a valid characterer to include in an identifier as defined by the jls
you'll find the definition of an identifier here
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now