class Test { void insideSwitch(Object o) { switch (o){ case /*unused*/ Object s /*unused*/ -> System.out.println(); } switch (o){ case Object s -> System.out.println(s); } switch (o) { case Object s when s != null -> System.out.println(); default -> System.out.println(); } } void insideInstanceOf(Object o) { if (o instanceof String s && s != null) { System.out.println(); } if (o instanceof String s) { System.out.println(s); } if (o instanceof String s) { System.out.println(); } } }