如何修复"运算符不能应用于 int[]、'int'?



我正在尝试检查"teamScore";。如果它小于2,我想把它循环回来。

String[] teamName = new String[teamNo];
int[] teamScore = new int[teamNo];
String[] Tevent = new String[teamNo];
for (int i = 0; i < teamNo; i++) {
System.out.printf("Enter Name of team " + (i + 1));
teamName[i] = scan.next();
System.out.println("Enter Name of the events that team"+ (i+1)+"is entering");
Tevent[i] = scan.next();
System.out.printf("Enter Total Score of team " + (i+1));
teamScore[i] = scan.nextInt();
if (teamScore<2){} 
// problem here it says operator cannot be applied to int[],'int'.
}

我尝试使用其他声明,如double。很确定事实并非如此。有什么解决方案吗?

它应该工作:

Scanner scan = new Scanner(System.in);
int teamNo = 1;
String[] teamName = new String[teamNo];
int[] teamScore = new int[teamNo];
String[] Tevent = new String[teamNo];
for (int i = 0; i < teamNo; i++) {
System.out.printf("Enter Name of team " + (i + 1));
teamName[i] = scan.next();
System.out.println("Enter Name of the events that team" + (i + 1) + "is entering");
Tevent[i] = scan.next();
System.out.printf("Enter Total Score of team " + (i + 1));
teamScore[i] = scan.nextInt();
if (teamScore[i] < 2) {

}
}

您需要给出要在数组上获得的索引。