String in Switch StatementIn 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:
be careful while passing string object, passing a null object cause to NullPointerException. String in Switch Statement Example 1Output: Let's play Cricket String in Switch Statement Example 2Output: This is a indoor game
Next TopicJava 7 Catch Multiple Exceptions
|