A scenario when ‘Brake’ and ‘Continue’ work equally

If you put a switch-case block inside a while loop, both brake and continue will work and the output will be same. E.g.

Int i=0;

while (i<6){

switch (i){

case 1:

system.out.println(“Inside case 1”);

i++;

continue;

case 2:

system.out.println(“Inside case 2”);

i++;

brake;

case 3:

system.out.println(“Inside case 3”);

i++;

continue;

case 4:

system.out.println(“Inside case 4”);

i++;

brake;

default:

system.out.println(“Inside Default”);

}

}

Any comments?

Advertisements

Leave a comment

Filed under Java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s