Вывод верный, но 3 условие никак не проходит. Подскажите, в чем проблема?
package com.javarush.task.task18.task1803;
/*
Самые частые байты
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;
public class Solution
{
public static void main(String[] args) throws Exception
{
List<Integer> list = new ArrayList<>();
List<Integer> counts = new ArrayList<>();
Map<Integer, Integer> map = new HashMap<>();
int count = 1;
try (FileInputStream inputStream = new FileInputStream(new BufferedReader(new InputStreamReader(System.in)).readLine()))
{
while (inputStream.available() > 0) list.add(inputStream.read());
}
Collections.sort(list);
for (int i = 0; i < list.size(); i++)
{
for (int j = i; j < list.size() - 1; j++)
{
if (list.get(i).equals(list.get(j + 1)))
{
count++;
}
else
{
map.put(list.get(i), count);
count = 1;
i = j;
break;
}
}
}
// Collections.max(map.values());
// System.out.println(list.toString());
// System.out.println(map.toString());
// System.out.println(Collections.max(map.values()));
// map.containsValue(Collections.max(map.values()));
Integer max = Collections.max(map.values());
for (Map.Entry<Integer, Integer> entry : map.entrySet())
{
if (entry.getValue().equals(max)) System.out.print(entry.getKey() + " ");
}
}
}