我遵循了该线程中提出的要点,但是出现错误“对于参数类型,运算符未定义[...]”
我的代码:
public class Test{
private int[] array = new int [5];
public int method(int i) {
for(int s = 0; s <= array.length; s++) {
if( array[s] != null) { //I get the error in here even though the highest upvoted answer in the linked question recommends this solution. I obviously cant check it for 0, because the user input can be 0.
array[s] = i;
} else {
method(i);
}
}
}
}
繁星coding
相关分类