This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes why variable names can't start with numericals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "why variable names can Watch "why variable names can New topic
Author

why variable names can't start with numericals

nitin kanwar
Greenhorn

Joined: Aug 20, 2011
Posts: 1
I was asked in an interview as to why the variable names can't start with a numerical value ? To be more precise the interviewer wanted to know the lexical / compilation problems associated with declaring a variable name that starts with a numerical ?

Answers will be appreciated.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to JavaRanch

think about this:

int 2L = 100;
long value = 2L;//what is the value of value variable?

and

int 4L = 200;
System.out.println(4L);//???


 
Consider Paul's rocket mass heater.
 
subject: why variable names can't start with numericals
 
Similar Threads
What's wrong with my hashCode() ?
variable names
Printing an array
Why volatile variable can't be serialized?
How to print the name of an object in java ?