cannot find symbol, symbol: method books(int[], int)
当我尝试编译以下代码时收到错误消息。
有关我希望代码执行的操作的进一步说明,请参见代码下方。
public class books {
public void main(String[] args) {
int searchValue = 0, index;
int refNum[] = new int[4]; // the array
refNum[0] = 4; //numbers to refer to (aka to find)
refNum[1] = 6;
refNum[2] = 10;
refNum[3] = 12;
refNum[4] = 14;
int input = Integer.parseInt(enterValue.getText()); //takes user's input
for (int x = 0; x < refNum.length; x++) {
refNum[x] = input; //Tells refNum value to be
}
searchValue = input;
index = books(refNum, searchValue); //"books" is underlined
if (index != -1) {
binarySearchField.setText("We found: " + index);
} else {
binarySearchField.setText("Sorry! Not Found!");
}
public static Boolean binarySearch(String [] refNum, int left, int right, String search){
//Boolean code for later
}
该程序使用二进制搜索在用户输入数字后查找存储在数组中的值,如果它们匹配则成功找到该项目。用户在文本字段“enterNumber”中输入所需的数字。现在在我的代码中)如果不是因为这件小事,我有 78% 的把握肯定会工作)有一个重要的下划线,不应该是,(我已经在要显示的行旁边评论)
现在我以为我应该把类名放在那里,但显然因为它带有下划线,所以情况并非如此。关于我应该放在那里的任何想法?
我很抱歉这个问题可能对我真正要问的有点误导,我只是不知道如何措辞这个问题。