Pattern matching for instanceof


Source code

1class PatternMatchingForInstanceof {
2
3 void m(Object obj) {
4 if (obj instanceof String s) {
5 s.charAt(1);
6 }
7 }
8
9}

Bytecode



Java compiler version: 21
Other examples
Main page