3ac3af2327
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 6m55s
28 lines
564 B
Java
28 lines
564 B
Java
import java.lang.Object;
|
|
import java.lang.String;
|
|
|
|
|
|
|
|
sealed interface List permits LinkedElem {}
|
|
|
|
|
|
public record LinkedElem<T>(T a,List l) implements List{} //Implementiert List und wird auch permittet
|
|
public record Elem<T>(T c) implements List{} //Implementiert List, wird aber nicht permittet
|
|
|
|
public class SwitchCaseHeritageDetection {
|
|
public main(o) {
|
|
return switch(o) {
|
|
case LinkedElem(a, Elem(e)) -> a ;
|
|
case LinkedElem(a, LinkedElem(e, Elem(f))) -> e;
|
|
default -> null;
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|