Showing posts with label Strings. Show all posts
Showing posts with label Strings. Show all posts

June 18, 2016

Switch Case With Strings | Java

22:21 Posted by Freblogg , , , No comments
Switch Case is certainly one of the most widely used programming constructs. It is just as widely used in Java as in any other language.java-logo
Up until Java 7, switch in Java did not support String type in the case statement. So, if you want to perform multiple comparisons on Strings, the only way you were able to do it was by using multiple If - Else Statements which is certainly not pretty!
But, then in Java 7 they have introduced Switch With Strings and it was welcomed by everyone who had to write those terrible if-else ladders. So, Let’s see how we can use Strings in a Case statement.