JAVA.SWITCH.NOBREAK
Switch case clause without break statement.
Vulnerability and risk
Forgetting a break statement in a switch case clause can cause unintended behavior. Unless you have an explicit reason, you should avoid omitting break statements.
Mitigation and prevention
Always use a break statement in a switch case clause.
Example 1
Copy
                                                    
                                                
                                            public class C19 {
    
    public int testNG(int i) {
        int ret = 0;
        switch(i) {
        case 1: //OK
            ret = 1;
            break;
        case 2:
            ret = 2; //NG
        default: //OK
            ret = 0;
        }
        return ret;
    }
}