Alex Rivera | Logout

Switch without break

Asked 2011-12-19T16:02:45.513
42

I have some switch statement as shown below. Notice there is no break. Findbugs is reporting error on the second case statement only. The error is : Switch statement found where one case falls through to the next case.

switch(x) {

    case 0:
        // code

    case 1:
        // code

    case 2:
        // code
}
Edit
Report

1 Answer

3

Switch fall-throughs fall under the Findbugs category of "dodgy code". I think it only flags the first occurrence of a fall-through in a switch statement to cut down on the number of error messages.

answered 2011-12-19T16:08:41.837

Your Answer