When I try to print myWords in a separate class, all I get a a blank statement. I'm pretty sure the code is right but I just can't get it to print the words that I want. Please help!
public String[] multiLetter (int n, char included)
//public String[] multiLetter(int n, char included)
//returns an array of words with at least m occurrences
//of the letter included
{
for (int i = 0 ; i < words.size() ; i++)
{
int repeatCounter = 0;
for (int j = 0 ; j < words.get(i).length(); j ++)
{
if (included == words.get(i).charAt(j))
{
repeatCounter ++;
}
}//closes inner for loop
if (repeatCounter >= n)
{
myWords.add(words.get(i));
}
}
String [] array = new String [myWords.size()];
return myWords.toArray(array);
}
List<String> myWords = new ArrayList<String>();. It is enough when myWords is local variable.