Skip to content

Latest commit

 

History

History
23 lines (21 loc) · 441 Bytes

strings.md

File metadata and controls

23 lines (21 loc) · 441 Bytes

Strings

As already shown, you can use a case to match String values.

~void main() {
String veggie = "cucumber";
switch (veggie) {
    case "cabbage" -> {
        System.out.println("A cabbage");
    }
    case "brussel sprout" -> {
        System.out.println("A brussel sprout");
    }
    case "cucumber" -> {
        System.out.println("A cucumber");
    }
    default -> {
        System.out.println("Other");
    }
}
~}