-4
ArrayList<History1> hist; //i have an class History1
hist= new ArrayList<>();
public class History{
x=text.gettext;
y=text1.gettext;
public History(){
for(History hiss: hist){
if(hiss.getint()==x && hiss.getint2()==y){
System.out.println("Already exists in stack")
}
else{
hist.add(new History1(x,y))
}
}
}
}
代码有问题,我无法找到它,这段代码不知道给定的值是否在arraylist或不....如果它是在arraylist中没有添加列表中的值其他它将该值添加为历史对象。如何知道数值是否在数组列表中?
是x和y整数?因为你将它们设置为text.gettext,然后与hiss.getint中的一个进行比较 – Jakob
请分享完整的代码 –
正如这里所写的那样,存在明显的问题,使得无法肯定地说。此外,请花时间以一致的方式格式化您的代码;不要让我们追逐'{}'s – ChiefTwoPencils