logical OR in Java not working?

Before you do anything check for an empty List or a 0 divisor.

if(divisor==0||array1.isEmpty()){
    return false;
}

Then you can check the list.

for(Integer i: array1){
    if(i%divisor!=0){
        return false;
    }
}

Finally.

return true;

Leave a Comment