Digital Marketing

Switch Expressions in Java

        int month=5;
String monthString;
monthString = switch (month) {
case 1 -> "January";
case 2 -> "February";
case 3 -> "March";
case 4 -> "April";
case 5 -> "May";
case 6 -> "June";
case 7 -> "July";
case 8 -> "August";
case 9 -> "September";
case 10 -> "October";
case 11 -> "November";
case 12 -> "December";
default -> "Invalid month";
};
System.out.println(monthString);

Comments

Popular posts from this blog

How to delete / clear queue of PowerMTA