gpt4 book ai didi

java - Java 中的整数类

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:48 25 4
gpt4 key购买 nike

<分区>

我不明白为什么输出不同。
输出仅在 -128 到 127 范围内相同。

public class Check {
public static void main(String[ ] args) {
Integer i1=122;
Integer i2=122;

if(i1==i2)
System.out.println("Both are same");
if(i1.equals(i2))
System.out.println("Both are meaningful same");
}
}

输出:
两者是一样的
两者意义相同

public class Check {
public static void main(String[] args) {
Integer i1=1000;
Integer i2=1000;

if(i1==i2)
System.out.println("Both are same");
if(i1.equals(i2))
System.out.println("Both are meaningful same");
}
}

输出: 两者意义相同

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