Add java17-features module: runnable demos and captured output for the ankurm.com java17-features article
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
$ javac broken/SealedViolation.java (17.0.20.1)
|
||||
broken/SealedViolation.java:5: error: class is not allowed to extend sealed class: Shape (as it is not listed in its permits clause)
|
||||
record Triangle(double b, double h) implements Shape {}
|
||||
^
|
||||
1 error
|
||||
|
||||
$ javac broken/RecordFieldMutation.java (17.0.20.1)
|
||||
broken/RecordFieldMutation.java:3: error: cannot assign a value to final variable x
|
||||
record Point(int x, int y) { void move() { this.x = 10; } }
|
||||
^
|
||||
1 error
|
||||
|
||||
$ javac broken/SwitchPatternOn17.java (17.0.20.1)
|
||||
broken/SwitchPatternOn17.java:3: error: patterns in switch statements are a preview feature and are disabled by default.
|
||||
static String f(Object o) { return switch (o) { case String s -> "string"; default -> "other"; }; }
|
||||
^
|
||||
(use --enable-preview to enable patterns in switch statements)
|
||||
1 error
|
||||
Reference in New Issue
Block a user