I want to execute code if NONE of the items in Arraylist have attribute ‘slotted’ set to false. I use the following code :
int p=0;
for (int i = 0; i < AppleList.size();i++){
if (AppleList.get(i).slotted = true){
p++;
}
if (p == 0){
//EXECUTE CODE
}
Is there any way to do this better?
You can do it using enhanced-for loop and a label: