19 lines
316 B
Java
19 lines
316 B
Java
import java.lang.Integer;
|
|
import java.lang.Float;
|
|
import java.lang.Number;
|
|
|
|
record Point(Number x, Number y) {}
|
|
|
|
public class OverloadPattern {
|
|
m(Point(Integer x, Integer y)) {
|
|
return x + y;
|
|
}
|
|
|
|
m(Point(Float x, Float y)) {
|
|
return x * y;
|
|
}
|
|
|
|
m(Integer x) {
|
|
return x;
|
|
}
|
|
} |