1
當我嘗試在單獨的類中打印myWords時,我得到一個空白語句。我很確定代碼是正確的,但我無法打印出我想要的單詞。請幫忙!打印數組語句
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);
}
你永遠不會打印任何東西。 –
您遺漏了足夠的相關信息,我們無法幫助您。 – csmckelvey
我們需要看到您嘗試打印陣列的類 –