Enhanced Switch
Enhanced switch এর সাহায্যে কোডটিকে ছোট করে ফেলা যায়। নিচে একটি উদাহরণ দেওয়া হল।
javabook.java
public class javabook {
public static void main(String[] args) {
char ch = 'a';
switch (ch) {
case 'a', 'f', 'g' -> System.out.println("This is an A");
case 'b' -> System.out.println("This is a B");
default -> System.out.println("Invalid");
}
}
}
Created with the Personal Edition of HelpNDoc: Revolutionize Your Documentation Output with HelpNDoc's Stunning User Interface