import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) throws Exception{ // map List<String> words = Arrays.asList("Hello", "World"); words.stream() .flatMap((String line) -> Arrays.stream(line.split(""))) .distinct() .forEach(System.out::println); } }