You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enum Direction {LEFT, RIGHT}
void displayDirection(Direction direction) {
switch(direction) {
case LEFT -> System.out.println("Turn Left");
case RIGHT -> System.out.println("Turn Right");
}
}
This is the correct java code. When I create method with this body though, it gets replaced with something like:
void displayDirection(Direction direction) {
switch(direction) {
case LEFT:
System.out.println("Turn Left");
yield;
case RIGHT:
System.out.println("Turn Right");
yield;
};
}
It seems as if I use "->" in standard switch, library automatically treats it as switch expression
The text was updated successfully, but these errors were encountered:
I can write the following method in Java:
This is the correct java code. When I create method with this body though, it gets replaced with something like:
It seems as if I use "->" in standard switch, library automatically treats it as switch expression
The text was updated successfully, but these errors were encountered: