私は Java の初心者で、BlueJ を使用しています。コンパイルしようとすると、「Int を逆参照できません」というエラーが表示され続けますが、何が問題なのかわかりません。エラーは、「equals」がエラーであり、「int を逆参照できない」と表示されている一番下の if ステートメントで具体的に発生しています。どうすればいいのか分からないので、何か参考になれば幸いです。前もって感謝します!
public class Catalog {
private Item[] list;
private int size;
// Construct an empty catalog with the specified capacity.
public Catalog(int max) {
list = new Item[max];
size = 0;
}
// Insert a new item into the catalog.
// Throw a CatalogFull exception if the catalog is full.
public void insert(Item obj) throws CatalogFull {
if (list.length == size) {
throw new CatalogFull();
}
list[size] = obj;
++size;
}
// Search the catalog for the item whose item number
// is the parameter id. Return the matching object
// if the search succeeds. Throw an ItemNotFound
// exception if the search fails.
public Item find(int id) throws ItemNotFound {
for (int pos = 0; pos < size; ++pos){
if (id.equals(list[pos].getItemNumber())){ //Getting error on "equals"
return list[pos];
}
else {
throw new ItemNotFound();
}
}
}
}