String in Switch Case in Java - GeeksforGeeks

PHOTO EMBED

Thu Sep 23 2021 01:00:20 GMT+0000 (Coordinated Universal Time)

Saved by @drack669 #java

// Java program to demonstrate use of a
// string to control a switch statement.
public class Test 
{
    public static void main(String[] args)
    {
        String str = "two";
        switch(str)
        {
            case "one":
                System.out.println("one");
                break;
            case "two":
                System.out.println("two");
                break;
            case "three":
                System.out.println("three");
                break;
            default:
                System.out.println("no match");
        }
    }
}
content_copyCOPY

https://www.geeksforgeeks.org/string-in-switch-case-in-java/