public static void main(String[] args) { String input = "123451212111"; Integer integer = input.chars() .boxed() .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) .entrySet() .stream() .max(Comparator.comparing(Map.Entry::getValue)) .map(entry -> entry.getKey()) .get(); System.out.println(Character.toChars(integer)); }