This feature allows for methods to be declared inside of other methods making them effectively private to that method. public static boolean anyMatch ( Graph graph , Predicate < Node > predicate ) { var seen = new HashSet < Node >(); boolean hasMatch ( Node node ) { if (! sealed interface Developer { } record Person ( String name , int age ) extends Developer { } record Business ( String name ) extends Developer { }