1

This question is a part of OCP test series .

> Integer i=new Integer(100_00);

I tried to understand how this works but so far i have only got this much that this is one of a message format . Please provide some clarity as to how we can pass a numeric value with a underscore . Pardon me if this is a simple concept but i am kind of anxious to know this .

0

1 Answer 1

5

Java allows numeric literals with _ for better readability.

For example:

int i = 10_000;
float pi =      3.14_15F;
Sign up to request clarification or add additional context in comments.

5 Comments

In other words, 10_000, 100_00 and 10000 are all the same; they all mean "ten thousand".
Thanks Jigar and Kevin . Your answers combined answer this . So this is just for readability . After your code gets compiled, these underscores are removed in bytecode stream ?
The compilation process itself deals with the underscores.
I am sorry deals ?
correct, int i = 100 and int i = 1_0_0 compiles to same thing

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.