尝试返回索引时出现错误(必须返回一个 int),我看不出我做错了什么。如何将 Object 数组索引与 int 进行比较,并返回索引号?
//x starts at 10000 because the left most number is assumed to be at least a 1.
/**
* Search for a book id within the Book object array
* @param Book - Array of objects with book id, title, isbn, author, and category
* @param numOfBooks - how many books are in the library
* @param myBookID - The key to search for
* @return the index of the array where the key matches
*/
public static int bookSearch (Object[] Book, int numOfBooks, int myBookID) {
for (int x = 10000; x <= numOfBooks; x ++)
if (Book[x].equals(myBookID))
return x;
}