인덱스를 반환하려고 할 때 오류가 발생합니다 (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;
}
같은 방법 위에 적용합니다. Java에서는 변수에 소문자를 사용해야합니다. – m0skit0
그게 내 강사가 정확한 변수 이름을 사용하여 지침을 입력 한 방법입니다 ... 반대하고 싶지 않았습니다. – trama
강사/강좌를 변경하는 것이 좋습니다. – m0skit0