`` `package com.bjss.tests.questions_interview;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public class printFirstDublicateOne {
public static void main(String[] args) {
{
String inputString = "mmJava Concept Of The Day".replaceAll(" ", "").toLowerCase();
System.out.println(inputString);
Map<String, Long> charCountMap =
Arrays.stream(inputString.split(""))
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
String firstRepeatedChar = charCountMap.entrySet()
.stream()
.filter(entry -> entry.getValue() > 1)
.map(entry -> entry.getKey())
.findFirst()
.get();
System.out.println(firstRepeatedChar);
}
}
}
`` in this code, the output is "a" but expected m, what can be the reason , I have debugged but can not find out the reason , any help really appreciated