Most specific condition first
When conditions overlap, the order of an else if chain decides the answer, and the most specific case has to come first. The classic example is FizzBuzz: print Fizz for multiples of 3, Buzz for multiples of 5, FizzBuzz for multiples of both, and the number itself otherwise.
int number = 15;
if (number % 3 == 0 && number % 5 == 0) {
System.out.println("FizzBuzz");
} else if (number % 3 == 0) {
System.out.println("Fizz");
} else if (number % 5 == 0) {
System.out.println("Buzz");
} else {
System.out.println(number);
}
FizzBuzz15 is a multiple of 3, so if the number % 3 == 0 check came first, it would print Fizz and never reach the combined case. Checking "both" first works, because every later branch can then assume that "both" was false.