gpt4 book ai didi

java - 如何匹配这两个值相同?

转载 作者:行者123 更新时间:2023-12-02 02:52:33 25 4
gpt4 key购买 nike

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中100010不一样。

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com