gpt4 book ai didi

java - 我收到以下代码的 [I cannot be cast to java.lang.Integer] 错误。有没有其他方法可以做到这一点

转载 作者:行者123 更新时间:2023-12-05 05:24:21 25 4
gpt4 key购买 nike

<分区>

我使用以下代码遇到错误。有没有其他方法可以做到这一点。

我收到以下代码的 [I cannot be cast to java.lang.Integer] 错误。有没有其他方法可以做到这一点。

package collectionTest;

import java.util.*;

public class ContinuesNumber {

public static void main(String[] args) {

int[] num = new int[]{3,5,81,6,3,789,67,56,79,8,76,80,6,77,7};

List<Integer> list = new ArrayList(Arrays.asList(num));

Set<Integer> count = new HashSet<Integer>();
Set<Integer> tmp = new HashSet<Integer>();

for(Integer i=0;i<list.size();i++)
{
int var = list.get(i);

int incr = var+1;
int decr = var-1;

tmp.add(list.get(i));
for(Integer j=i+1;j<list.size();j++)
{
if(incr==list.get(j) || decr==list.get(j))
{
tmp.add(list.get(j));
if(list.get(j)>list.get(i))
incr++;
else
decr--;
continue;
}
else
{
list.remove(list.get(j));
}
}
}
if(count.size()>tmp.size())
{
count.addAll(tmp);
}

System.out.println("most continuous elements are : "+ count);
}
}

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