Switch is mostly useful while we are making any menu-driven program and we can use switch even for many other purposes. Here I’m going to show you the use of switch which is very simple. Actually the switch work also can be done via if-else-if.

This example shows how to return the month name when we only give the month number.All the stuffs are being handled by the method getMethod() it will see if the month matches with the case from 1-12 if no any case is matched it would go to default: and returns ‘Invalid Month’

In this code you can see the use of switch method .