Control flow / Conditional statements / switch/case statements

record Point<T>(T x, T y) {}

<TString describe(Point<T> point) {
    return switch (point) {
        case Point(Integer x, Integer y) -> "Point (int, int)";
        case Point(Float x, Float y) -> "Point (float, float)";
        case Point(var x, var y) ->
            String.format("Point (%s, %s)", x, y);
        default -> "Unknown";
    };
}

var p1 = new Point<Integer>(34);
var desc1 = describe(p1);
System.out.println("desc1 is " + desc1);

var p2 = new Point<Double>(7.14.6);
var desc2 = describe(p2);
System.out.println("desc2 is " + desc2);