Simple example to switch statements using string. Syntax : switch(String variable) { case "" : case "" : case "" : : : . } Example : public class StringSwitchDemo { public static void main(String[] args) { StringSwitchDemo demo = new StringSwitchDemo(); String day = "Sunday"; switch (day) { case "Sunday": demo.doSomething(); break; case "Monday": demo.doSomethingElse(); break; case "Tuesday": case "Wednesday": demo.doSomeOtherThings(); break; default:
LEARN | EXPLORE | INNOVATE