Add java21-features module: runnable demos and captured output for the ankurm.com java21-features article
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
/** Fails to compile on purpose: a pattern switch over a sealed type must cover every permitted subtype. */
|
||||
public class NonExhaustive {
|
||||
sealed interface S permits A, B {}
|
||||
record A() implements S {}
|
||||
record B() implements S {}
|
||||
static String f(S s) { return switch (s) { case A a -> "a"; }; }
|
||||
public static void main(String[] args) { }
|
||||
}
|
||||
Reference in New Issue
Block a user