I do not understand why it does not work
package fr.codegym.task.task10.task1016;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*
Mots identiques dans une liste
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader lecteur = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> mots = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
mots.add(lecteur.readLine());
}
Map<String, Integer> map = compterMots(mots);
for (Map.Entry<String, Integer> paire : map.entrySet()) {
System.out.println(paire.getKey() + " " + paire.getValue());
}
}
public static Map<String, Integer> compterMots(ArrayList<String> liste) {
HashMap<String, Integer> resultat = new HashMap<String, Integer>();
String curence = liste.get(0);
int n;
for(int d = 1;d<liste.size();d++){
n = 1;
curence = liste.get(0);
for(int i = 1;i<liste.size();i++){
if(curence.equals(liste.get(i))){
n++;
liste.remove(i);
i--;
}
}
resultat.put(curence, n);
liste.remove(0);}
//écris ton code ici
return resultat;
}
}