Javatpoint Logo
Javatpoint Logo

String in Switch Statement

In Java 7, Java allows you to use string objects in the expression of switch statement. In order to use string, you need to consider the following points:

  • It must be only string object.
  • String object is case sensitive.
  • No Null object

be careful while passing string object, passing a null object cause to NullPointerException.

String in Switch Statement Example 1


Let's play Cricket

String in Switch Statement Example 2


This is a indoor game

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA