Не понимаю, вроде бы всё верно работает, почему не пропускает? 😑
package com.javarush.task.task18.task1821;
/*
Встречаемость символов
*/
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
public class Solution {
public static void main(String[] args) {
try {
BufferedReader readParameter = new BufferedReader(new FileReader(args[0]));
SortedMap<Character, Integer> howOften = new TreeMap<>();
int count = 0;
String all = new String();
while (readParameter.ready()) {
all += readParameter.readLine().replaceAll(" ", "");
}
for (int i = 0; i < all.length(); i++) {
for (int j = 0; j < all.length(); j++) {
if (all.charAt(i) == all.charAt(j)) {
count++;
}
}
howOften.put(all.charAt(i), count);
count = 0;
}
for (Map.Entry<Character, Integer> mapy : howOften.entrySet()) {
System.out.println(mapy.getKey() + " " + mapy.getValue());
}
readParameter.close();
} catch (FileNotFoundException e) { } catch (IOException e) { }
}
}