Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- public static void main(String[] args) {
- String input = "java spring boot java santosh";
- String key = Arrays.stream(input.split(""))
- .collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting())).
- entrySet().stream().filter(x -> x.getValue() == 1).findFirst().get().getKey();
- System.out.println(key);
- LinkedHashMap<String, Long> map = Arrays.stream(input.split(""))
- .collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()));
- String result = map.entrySet().stream().filter(x -> x.getValue() == 1).findFirst().get().getKey();
- System.out.println(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement