+ 11
In java why Systems.out.println(1_0 == 10); gives true ?
12 ответов
+ 27
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.
Here you will find more information (scroll all the way down)
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
+ 9
0_9 gives compile time error.
If you put 0 in front of a number, then you are using Octal number system
01=1
02=2
07=7
010=8
011=9...
+ 7
I just learnt that underscore sign is set to improve readability
from _voja_
+ 6
voja and 10 are both readable without underscores. Just saying.
+ 6
I dont tink so...,
09 is not an integer value
+ 5
Sonic yah
But dats a good system
+ 5
Is 0_9==9 ?
+ 5
Using Underscore Characters in Numeric Literals
In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example. to separate groups of digits in numeric literals, which can improve the readability of your code.
For instance, if your code contains numbers with many digits, you can use an underscore character to separate digits in groups of three, similar to how you would use a punctuation mark like a comma, or a space, as a separator.
+ 4
Y if we give 09 to a number it takes as 9
+ 4
Tqsm
+ 4
Underscore just separates doesn't change the way the number is written😊
+ 3
Hey,Hii there.underscore is mainly used in the variable naming as we can name the variable with mix of numbers and alphabet by using this underscore.
BUT IT WONT HAVE ANY EFFECT ON CONSTANTS..
Ex: Customer_id=12
print(200=20_0)
HOPE IT HELPS..
HAPPY CODING😀😀