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
ArrayList
@param names: the given names to find number of occurrence in words
@param words: the given words in document
@return: the ArrayList
** 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
Get step-by-step solutions from verified subject matter experts
