Syntax error, insert ";" to complete LocalVariableDeclarationStatement
Syntax error on token "yield", AssignmentOperator expected after this token
public class X {
public static void main(String[] args) {
Object x = "Hello";
String j = switch (x) {
case String s : yield "String";
default : { System.out.println();
yield "Default";
}
}
}
}
The second one is not helpful and head scratch inducing.
(2) This program generates: C cannot be resolved or is not a field which is not quite the case even though the error is valid.
public class X {
enum E1 {
A;
}
enum E2 {
B;
}
public static final int C = 42;
public static void main(String[] args) {
}
void foo(E1 e1) {
switch (e1) {
case A :
case C :
}
System.out.println(C);
}
}
This program generates two errors:
The second one is not helpful and head scratch inducing.
(2) This program generates:
C cannot be resolved or is not a field
which is not quite the case even though the error is valid.