Java words frequency count check
<p>In this program, I would like to implement a method that find the duplicate words and frequency. Then return Pair(word, frequency); Everything need to be done in one implementing method.Start with</p>

<pre><code>public Collection&lt;Pair&lt;String, Integer&gt;&gt; getAnswer(CharacterReader characterReader)
</code></pre>

<p>Furthermore, in the CharacterReader class, there is a build in method for read next character. 
The output of this method for example, it was cool, it was good. </p>

<pre><code>Output: 
it - 2
was - 2
cool -1 
good -1 
</code></pre>

<p>Frequency should be in descending order, and if two words have the same frequency, then it should output as alphabetical order. This is my code so far. </p>

<pre><code>import CharacterReader;
import util.Pair;

//including API collection
import java.util.Collection;

public class AnswerOne
{
    //CharacterReader is a interface, which contain a method of to read next character
    public Collection&lt;Pair&lt;String, Integer&gt;&gt; getAnswer(CharacterReader characterReader)
    {
        throw new UnsupportedOperationException( "You must provide an implementation for this method as part of your solution." );

      //mapping string with integer, words with frequency 
     final TreeMap&lt;String, Integer&gt; frequencyMap = new TreeMap&lt;String, Integer&gt;(); 

     //get the next word
    String word = character.getNextChar();

    //convert very words to lower case
    word = word.toLowerCase();

     final StringTokenizer delimit = new StringTokenizer(word, "\n");

    while (delimit.hasMoreToken()) {

        final String currentWord = delimit.nextToken();
        Integer frequency   = frequencyMap.get(word);
        if(frequency==null){
            frequency = 0;
        }

        frequencyMap.put(word,frequency+1); 
    }   

     return new Pair&lt;String,Integer&gt;(words, frequency);
    }    
  }
</code></pre>

<p>Can anyone give me any advices of how I can make this program work. Thank you</p>
