public static Map<String, Integer> countWords(ArrayList<String> list) {
    HashMap<String, Integer> result = new HashMap<String, Integer>();
    int count = 0;
    for (int i = 0; i < list.size() ; i++) {
        for (int j = i + 1; j < list.size(); j++) {
            String word = list.get(i);
            String anotherWord = list.get(j);
            if (word != null) {
            if (word == anotherWord){
                count++;
                result.put(word, count);

            } else if (word != anotherWord){
                count++;
                result.put(word,count);
            }
        }
    }
Валидатор не пропускает, сдаётся мне, что я перемудрил с кодом. В чём ошибка?