Jestem całkiem nowy w Javie i używam BlueJ. Wciąż próbuję uzyskać błąd "Nie można odrzucić" podczas próby kompilacji i nie jestem pewien, na czym polega problem. Błąd występuje szczególnie w moim oświadczeniu na dole, gdzie "równy" jest błędem i "int nie może być zniesiony". Mam nadzieję, że otrzymam pomoc, ponieważ nie mam pojęcia, co robić. Z góry dziękuję!"int nie może być dereferenced" w Javie
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();
}
}
}
}
Starasz się przy użyciu 'int' gdzie' Integer', '' Number' lub oczekuje Object' ... 'int 'nie ma żadnych metod. – MadProgrammer