0

Sample output All Is Well : { =2, A=1, s=1, e=1, W=1, I=1, l=4}

1 Answers1

0

You may try this,

    Arrays.stream("inputstring".split(""))
            .map(String::toLowerCase)
            .collect(Collectors.groupingBy(s -> s, LinkedHashMap::new, Collectors.counting()))
            .forEach((k, v) -> System.out.println(k + " = " + v));
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 04 '22 at 22:58