import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.stream.Collectors;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        List<String> values = List.of("java", "javascript", "python", "go", "java");

       TreeSet<String> sortedByLength = values.stream()
            .collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparingInt(String::length))));
        
        System.out.println(sortedByLength);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: