你好,我正在开发一个使用arraylists的应用程序(仅为练习而非真正的应用程序)
我创建了一个方法来给出一个数学答案,但只有在arraylist中不包含对象时才能使用。出于某种原因,我总是看到if/else结构中的else部分。
这是我检查arraylist是否包含对象的方法:
public void sluitRegistratie() {
aantalBezoekers = bezoeker.size();
if(!(aantalBezoekers >= 0)) {
String str = "Gemiddelde tijd bezoekers: " + (gesommeerdeTijd / aantalBezoekers);
JOptionPane.showMessageDialog(null, str);
}
else {
JOptionPane.showMessageDialog(null, "Bezoekers zijn nog niet weg");
}
}