java integer 128_JAVA:当Integer大于128时比较不起作用

我已经摘录并简化了Java程序的这一部分来进行测试。任务是比较ArrayList中的两个整数并声明它们是否相等。

以下代码适用于数字<128,但任何大于128的数字,该代码将不起作用。

任何帮助都将非常棒,谢谢。

import java.util.*;

public class test

{

public static void main (String[] args)

{

Integer seat1Store = 128;

Integer seat2Store = 128;

Integer seat3Store = 0;

Integer seat4Store = 0;

Integer seat5Store = 0;

ArrayList proceedArray = new ArrayList();

if (seat1Store !=0)

{

proceedArray.add(seat1Store);

}

if (seat2Store !=0)

{

proceedArray.add(seat2Store);

}

if (seat3Store !=0)

{

proceedArray.add(seat3Store);

}

if (seat4Store !=0)

{

proceedArray.add(seat4Store);

}

if (seat5Store !=0)

{

proceedArray.add(seat5Store);

}

System.out.println("ArrayList = " + proceedArray);

boolean proceed = false;

for(int i = 0; i

{

for(int p=0; p

{

if(i != p)

{

if(proceedArray.get(i) == proceedArray.get(p))

{

System.out.println("DUPLICATE");

System.exit(0);

}

}

}

proceed = true;

}

if (proceed == true)

{

System.out.println("PROCEEDED");

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值