xxxxxxxxxx
public WordPairList(String[] words)
{
allPairs = new ArrayList<WordPair>();
for(int i = 0; i < words.length; i++)
for(int j = i + 1; j < words.length; j++)
allPairs.add(new WordPair(words[i], words[j]));
}
xxxxxxxxxx
public int numMatches()
{
int matches = 0;
for(WordPair wp : allPairs)
if(wp.getFirst().equals(wp.getSecond()))
matches++;
return matches;
}