Я довольно новичок в Java, и я использую BlueJ. Я продолжаю получать эту ошибку «Int не может быть разыменован» при попытке скомпилировать, и я не уверен, в чем проблема. Ошибка происходит конкретно в моей инструкции if внизу, где она говорит, что «равно» является ошибкой, и «int не может быть разыменован». Надеюсь получить помощь, поскольку я понятия не имею, что делать. Заранее спасибо!«int не может быть разыменован» в Java
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();
}
}
}
}
Вы пытаетесь с помощью 'int' где' Integer', '' Number' или Object', как ожидается, ... 'ИНТ 'не имеет методов – MadProgrammer