You need to understand the characteristics of the switch-statement very clearly.
In switch-statement, every case checks the individual and original condition. For every false statement, it moves forward and for a true condition, it stops checking and break the loop.
The problem occurred when you used the uninitialized variable i in your second case within the same block. You need to initialize that variable in every case or make another block for the second case. Like this:
int i = 42;
I hope I am able to clear the things to you.