2023-07-04 13:27:29 +00:00
|
|
|
import java.lang.Integer;
|
2023-07-07 07:24:45 +00:00
|
|
|
import java.lang.Boolean;
|
2023-07-04 13:27:29 +00:00
|
|
|
import java.lang.String;
|
2023-07-06 20:15:40 +00:00
|
|
|
import java.lang.Object;
|
2023-07-04 13:27:29 +00:00
|
|
|
|
|
|
|
class SwitchStatement {
|
|
|
|
|
2023-07-11 20:15:35 +00:00
|
|
|
switchStandard(){
|
2023-07-04 13:27:29 +00:00
|
|
|
str = "SwitchMe";
|
|
|
|
switch(str){
|
|
|
|
case String s: return true;
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-11 20:15:35 +00:00
|
|
|
switchInteger(){
|
2023-07-04 13:27:29 +00:00
|
|
|
i = 5;
|
|
|
|
switch(i){
|
|
|
|
case Integer j:
|
|
|
|
case String s: i = 6; break;
|
|
|
|
default: i = 0; break;
|
|
|
|
}
|
|
|
|
return (i==0);
|
|
|
|
}
|
|
|
|
|
2023-07-11 20:15:35 +00:00
|
|
|
guardedPattern(){
|
2023-07-04 13:27:29 +00:00
|
|
|
var i = 1;
|
|
|
|
switch(i){
|
|
|
|
case Integer j && j == 1: return true;
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-06 20:15:40 +00:00
|
|
|
record Coordinates(double x, double y) {}
|
|
|
|
|
2023-07-11 20:15:35 +00:00
|
|
|
recordPattern(Object obj){
|
2023-07-06 20:15:40 +00:00
|
|
|
switch(obj){
|
|
|
|
case Coordinates(double lat, double lon): return true;
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
2023-07-11 20:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
record SwitchExpression(int x, int y){
|
|
|
|
|
|
|
|
boolean switchStandard(str){
|
|
|
|
return switch(str){
|
|
|
|
case String s -> yield true;
|
|
|
|
default -> yield false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|