Switch Lambda Operator in Java

Run Settings
LanguageJava
Language Version
Run Command
class Main { public static void main(String[] args) { String str = "N"; String result = switch(str) { case "A" -> "for Apple"; case "B" -> "for Ball"; case "C" -> "for Cat"; case "D" -> "for Dog"; default -> "for another else"; }; System.out.println(str + " " + result); int i = 10; int j = 0; System.out.println(calculate(i, j, "*")); } public static double calculate(int a, int b, String operator) { return switch(operator) { case "+" -> a + b; case "-" -> a - b; case "*" -> a * b; case "/" -> (double) a / b; default -> 0; }; } }
Editor Settings
Theme
Key bindings
Full width
Lines