Java – why is “010” equal to 8?
•
Java
My simple question is why:
System.out.println(010|4);
Print "12"? I understand the bitwise OR operator, but why is "010" equal to 8? This is definitely not a compliment 2 notice, so how to decode this number?
Solution
Take a look at the Java language specification, chapter 3.10 1 Integer Literals
Now you should understand why 010 is 8
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码