0

System.out.print(1_0 ==10); Ans: true

When I compiled this line Ans is always true.. I didn't understand the concept behind it!!! Anyone Pls help!!!

21st Feb 2020, 6:59 PM
Neel _22
Neel _22 - avatar
2 Respuestas
+ 5
Underscores were introduced in Java to enhance readability of large numbers and it is completely legal to use. There is no difference between them. The compiler just ignores the underscore.
21st Feb 2020, 7:04 PM
Avinesh
Avinesh - avatar
+ 5
Numeric literals in Java can contain underscore, as long as it is not directly next to the decimal separator. This feature is supposed to make it easier to write / read long numbers, like you can write two millions as 2_000_000 instead of 2000000 Easier to read right?
21st Feb 2020, 7:04 PM
Tibor Santa
Tibor Santa - avatar