Question: Please help me find solution to this method in JAVA: Use Given Pair class : public class Pair{ String name ; int count ; public

Please help me find solution to this method in JAVA:

Use Given Pair class :

public class Pair{

String name;

int count;

public Pair(String name){

this.name = name;

this.count = 1;

}

public Pair(String name, int count){

this.name = name;

this.count = count;

}

public String getName(){

return name;

}

public int getCount(){

return count;

}

public void incrementCount(){

this.count++;

}

}

public static ArrayList getNameCounts(AbstractList names,

ArrayList words) {

@param names: the given names to find number of occurrence in words

@param words: the given words in document

@return: the ArrayList containing the pairs

** If Pair already exists within Pair List, you have to increment the count, instead of creating a new pair.**

Example)

Names = {hi, bye}

Words = {hi, cry, hi, bye, shy, cry}

ArrayList should contain Pairs (hi, 2) and (bye, 1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!