[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

why is int e# an incorrect variable name?

Posted on 2011-04-29
4
Medium Priority
?
810 Views
Last Modified: 2012-05-11
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
Comment
Question by:bachstein
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 35490930
You can test any non-start character with
System.out.println(Character.isJavaIdentifierPart('#'));

Open in new window

0
 

Author Comment

by:bachstein
ID: 35490962
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 35491051
iirc only numbers, letters and underscores. The first of these can't start an identifier
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 35495034
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question