Counting five specific words in a file
You can use a Map :

Map&lt;String,Integer&gt; freq = new HashMap&lt;String,Integer&gt;();
for(String word : words) {
    String w = word.toLowerCase();
    if (freq.containsKey(w)) {
        freq.put(w,freq.get(w)+1);
    } else {
        freq.put(w,1);
    }
}