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;

Modulo operator

The meaning of Mod is that you take the remainder after doing the division. 1 fits zero times in 4, so the remainder is 1. Here the wikipedia definition that explains in a little more detail: In mathematics the result of the modulo operation is the remainder of an arithmetic division. As is well known, … Read more