I want to remove duplicated characters and spaces with java 8 streams api but my code is not working :
Stream.of(sentence.toCharArray()).flatMap(x->Character.valueOf(x)).
distinct().sorted().forEach(System.out::print);
Please suggest a way use stream api for this.