On official Java site I came across this lines
you cannot place underscores in the following places:
At the beginning or end of a number...
Also they have given a example
int x1 = _52; // This is an identifier, not a numeric literal
When I used it in my code it didn’t gave any compile time error
long l = _23L;
Can we use _ at the beginning?
What does it mean by
This is an identifier, not a numeric literal
Sorry if it is a really silly question, I haven’t revised Java basics from long time.
EDIT :
I am using Windows XP and Java 7
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)
Literals are any thing which you hardcoded in the code like:
In this
10andhelloare literals.So numeric literal is nothing but literal having numerical value.
Identifiers are names given to objects, classes etc. but cannot be
keywordslike int, boolean, null etc.So in above example
x, str and Stringare identifiers.SIDE NOTE: How you define numerical literals are different from JDK 6 to JDK 7. So code in question will only run for JDK7