I understand the ASCII sort order is included in TreeMap , but something is wrong with it .
The problem is , that program running in IDE , and everything is right , I check it 10 times;
But compile say me that I am stupid , help me to understand what I am doing wrong;
package com.codegym.task.task18.task1821;
/*
Symbol frequency
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException{
TreeMap<Character , Integer> map = new TreeMap<Character , Integer>();
String fileName = args[0];
Reader reader = new FileReader(fileName);
BufferedReader br = new BufferedReader(reader);
String line;
while((line = br.readLine()) != null) {
char[] mass = line.toCharArray();
for (int i = 0 ; i < mass.length ; i++) {
char c = mass[i];
if (!map.containsKey(c)) {
map.put(c, 1);
}
else if (map.containsKey(c)) {
map.put(c, map.get(c) + 1);
}
}
}
br.close();
for (Map.Entry<Character, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
}
}