Again and Again prints the same value

后端 未结 3 1813
孤街浪徒
孤街浪徒 2021-01-17 09:01

I have been asked to check the number of times a team\'s name is on the text that is on my computer. I wrote the code, the code works fine by counting the number of times th

3条回答
  •  时光取名叫无心
    2021-01-17 10:00

    In the method checkSeries1() remove the method call for getName(teamName) out of for loop and call getName() only once outside for loop, like this:

    int count = 0;
    String name = getName(teamName);
    for ( int  index = 0 ; index < winners.length ; index ++ )
    {
        if ( name.equals(winners[index]))
        {
            count++;
        }
    }
    

提交回复
热议问题