Getting Started with Java
This is a 100% free course, but we need you to first join or login to watch this video.Alright, join or login here.
This video shows you an example of switch statement in Java. The switch statement takes a variable and compares its value with the all the cases that you write inside the switch statement. Each case can optionally add a break statement at the end. If you don’t add the break statement, the code starts executing at the point where the case matches the value of the variable and ends when it finds the first break statement regardless of how many cases were present in between. The default case is optional and is triggered when the value of the variable does not match with any of the listed cases.