Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

March 24, 2010

Why can’t variable names start with numbers?

Because then a string of digits would be a valid identifier as well as a valid number.

int 17 = 497;
int 42 = 6 * 9;
String 1111 = "Totally text";

int 2d = 42;
double a = 2d;
What is a? 2.0? or 42?

Hint, if you don't get it, d after a number means the number before it is a double literal

http://stackoverflow.com/questions/342152/why-cant-variable-names-start-with-numbers

No comments: