class LetsComp {
public static void main(String[] args) {
int a = 10, b = 0010;
System.out.println(a == b); // this gives false, even if both values in actual are same
}
}
最佳答案
在java中10
和0010
不一样。
0010
的八进制相当于 8
(十进制),而 10
已经是十进制格式。
来自JLS :
An octal numeral consists of an ASCII digit 0 followed by one or more of the ASCII digits 0 through 7 interspersed with underscores, and can represent a positive, zero, or negative integer.
关于java - 如何匹配这两个值相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43589105/