Question: (a) Write the constructor for the WordPairList class. The constructor takes an array of strings words as a parameter and initializes the instance variable
(a) Write the constructor for the WordPairList class. The constructor takes an array of strings words as a parameter and initializes the instance variable allPairs to an ArrayList of WordPair objects. A WordPair object consists of a word from the array paired with a word that appears later in the array. The allPairs list contains WordPair objects (words [i], words [j]) for every i and j, where 0 i (b) Write the WordPairList method numMatches. This method returns the number of WordPair objects in allPairs for which the two strings match.
Step by Step Solution
3.60 Rating (150 Votes )
There are 3 Steps involved in it
Heres the constructor for the WordPairList class java import javautilArrayList public class WordPair... View full answer
Get step-by-step solutions from verified subject matter experts
