What does this program print?

from Sealed classes
Java 25 LTS beginner 2 min

What does this program print?

Java
public class Main {
    sealed interface Result permits Ok, Failed {}
    record Ok(int value) implements Result {}
    record Failed(String reason) implements Result {}

    static String show(Result result) {
        return switch (result) {
            case Ok ok -> "value=" + ok.value();
            case Failed failed -> "error=" + failed.reason();
        };
    }

    public static void main(String[] args) {
        System.out.println(show(new Ok(7)));
        System.out.println(show(new Failed("timeout")));
    }
}
Open in playground
Report an error