"if" doesn't work while "switch" does

String doesn’t work with ==
better use equals() : if (myString.equals("Hello")) ....

switch() {.....} works with String

2 Likes