JavaCompilerCore/Switch.java

22 lines
517 B
Java
Raw Normal View History

2023-10-17 10:26:40 +00:00
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);
}
}
}