Java maintenance and ecosystem

Original stream reasoning exercise

Distinct removes duplicates and sorted orders the strings before collection. Predict the result before running.

Formal Syntax & Structure

java syntaxjava
stream().distinct().sorted().toList()

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) throws Exception {        var items=java.util.List.of("pen","book","pen");        System.out.println(items.stream().distinct().sorted().toList());    }}
Java Reference