public class Switch { public static void main(String[] args) { CharSequence s = "some string"; /*var res = switch (s) { case "AaAaAa" -> 20; case "AaAaBB" -> 30; case String y -> 40; case CharSequence cs -> 30; };*/ var i = s instanceof String s2; //System.out.println(s2); if (!(s instanceof String s2)) { System.out.println(s2); } else { System.out.println(s2); } } }