Facebook
From Sludgy Frog, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 218
  1.  public static void main(String[] args) {
  2.             String input = "123451212111";
  3.             Integer integer = input.chars()
  4.                     .boxed()
  5.                     .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
  6.                     .entrySet()
  7.                     .stream()
  8.                     .max(Comparator.comparing(Map.Entry::getValue))
  9.                     .map(entry -> entry.getKey())
  10.                     .get();
  11.  
  12.             System.out.println(Character.toChars(integer));
  13.         }