您好我正在尝试使用嵌套的 for 循环查找两个字符串数组之间的匹配项。然而,它似乎已经循环了更多次。
for(int i = 0; i < ca; i++) //ca contains 10
{
for(int j = 0; j < ra; j++) //ra contains 10
{
if(cAnswers[i].equals(rAnswers[j]))
{
count++; //Increments count to indicate a match
System.out.println("The current count: " + count); //To check the count
}
}
}
System.out.println("The number of correct questions is " + count + "/10"); //The result currently gives me 50/10 no matter what.
我尝试使用 <= 而不仅仅是 < 但最终使索引超出范围。