t0nyz

Untitled

Jul 26th, 2021
662
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static String mostPopularSpecialization(List<Doctor> doctorList) {
  2.         isEmpty(doctorList);
  3.         for (Doctor d : doctorList) {
  4.             if (!specializationAmountOfDoctors.containsKey(d.getSpeciality())) {
  5.                 specializationAmountOfDoctors.put(d.getSpeciality(), 1);
  6.             } else {
  7.                 int tmp = specializationAmountOfDoctors.get(d.getSpeciality());
  8.                 specializationAmountOfDoctors.put(d.getSpeciality(), tmp + 1);
  9.             }
  10.         }
  11.         Map.Entry<String, Integer> specializationMax = specializationAmountOfDoctors.entrySet().stream().max(Comparator.comparingInt(Map.Entry::getValue)).get();
  12.         return specializationMax.getKey() + " ---> " + specializationMax.getValue();
RAW Paste Data