+ 1

1_0==10 ?

System.out.print (1_0==10); // why it is true?

23rd Apr 2020, 12:44 PM
Zhengrong Yan
Zhengrong Yan - avatar
3 Answers
+ 1
Because 1_0 is 10. Underscore just separates digits so you can read numbers more easily. x= 1000000 is not so easy to read, x= 1_000_000 now you can easily see that x is one million.
23rd Apr 2020, 1:06 PM
Prabhat Ranjan
Prabhat Ranjan - avatar
0
It's a type of representation of numbers, used in some scientific notations of numbers.. The compiler just ingore _ in between numbers.. So it is true according to JVM. Edit: David Yan for more information See thses.. Saying added feature for improve readability... https://stackoverflow.com/questions/19806632/how-numeric-literal-with-underscore-works-in-java-and-why-it-was-added-as-part-o https://www.google.com/amp/s/www.geeksforgeeks.org/g-fact-45-using-underscore-in-numeric-literals/amp/
23rd Apr 2020, 12:59 PM
Jayakrishna 🇼🇳
23rd Apr 2020, 1:07 PM
Abhay
Abhay - avatar