package com.javainspires.examples; import java.util.LinkedHashMap; import java.util.function.Function; import java.util.stream.Collectors; public class ExampleMain{ public static void main(String[] args) { String input = "JJavva Inspires Is HelpFul"; Character result = input.chars() .mapToObj(c->Character.toLowerCase(Character.valueOf((char) c))) .collect(Collectors.groupingBy( Function.identity(), LinkedHashMap::new,Collectors.counting() )).entrySet() .stream() .filter(e-> e.getValue()==1) .map(e->e.getKey()) .findFirst() .get(); System.out.println(result); } }
Tags:
java programs