Ashley P.

asked • 10/01/19

Java Switch Case

Why is the output of the code 14, not 8 : alpha=3+5=8?


public class Application4{


public static void main(String[] args) {

int alpha=3;

int beta=5;


switch (beta){

case 3:alpha=alpha+3;

case 4:alpha=alpha+4;

case 5:alpha=alpha+5;

default:alpha=alpha+6;


}


System.out.println(alpha);

}

}


1 Expert Answer

By:

Ashkan E. answered • 10/01/19

PhD in Computer System and Software

Ashley P.

Great, now only I got it!
Report

10/03/19

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.