Java logoJava/
JAVA-W0411

Method uses the same code for multiple branchesJAVA-W0411

Minor severityMinor
Anti-pattern categoryAnti-pattern

This method seems to have the same code for multiple branch statements.

This could be a valid usage for clarity's sake, but it might also indicate a typo.

Bad Practice

if (someCondition) {
    System.out.println("a");
    System.out.println(1 + new Random().nextInt());
} else if (someOtherCondition) { // The else if block has the same content as the first if block...
    System.out.println("a");
    System.out.println(1 + new Random().nextInt());
} else if (new Random().nextBoolean()) {
    if ("3".equals("4")) System.out.println(3 + new Random().nextInt());
}

If the duplication was intended, consider just combining the conditions with an OR operator:

if (someCondition || someOtherCondition) {
    System.out.println("a");
    System.out.println(1 + new Random().nextInt());
}

References