I'm storing my wordcount into the value field of a HashMap, how can I then get the 500 top words in the text?
 public ArrayList<String> topWords (int numberOfWordsToFind, ArrayList<String> theText) {
        //ArrayList<String> frequentWords = new ArrayList<String>();
        ArrayList<String> topWordsArray= new ArrayList<String>();
        HashMap<String,Integer> frequentWords = new HashMap<String,Integer>();
        int wordCounter=0;
        for (int i=0; i<theText.size();i++){
                  if(frequentWords.containsKey(theText.get(i))){
                       //find value and increment
                      wordCounter=frequentWords.get(theText.get(i));
                      wordCounter++;
                      frequentWords.put(theText.get(i),wordCounter);
                  }
                else {
                  //new word
                  frequentWords.put(theText.get(i),1);
                }
        }
        for (int i=0; i<theText.size();i++){
            if (frequentWords.containsKey(theText.get(i))){
                 // what to write here?
                frequentWords.get(theText.get(i));
            }
        }
        return topWordsArray;
    }
 
     
    