17 lines
316 B
Plaintext
17 lines
316 B
Plaintext
|
import java.lang.Integer;
|
||
|
import java.lang.Double;
|
||
|
import java.lang.Number;
|
||
|
|
||
|
public record R(Number n) {}
|
||
|
|
||
|
public class SwitchOverload {
|
||
|
|
||
|
Number f(Double d) { return d * 2; }
|
||
|
Number f(Integer i) { return i * 5; }
|
||
|
|
||
|
public m(r) {
|
||
|
return switch(r) {
|
||
|
case R(o) -> f(o);
|
||
|
};
|
||
|
}
|
||
|
}
|