姬長信(Redy)

JAVA:当Integer大于128时,比较不起作用


这是我的Java程序的一部分,我已经拿出并简化了测试.任务是比较ArrayList中的两个整数并说明它们是否相等.

以下代码适用于数字 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