Hi im just learning java and don't know what would be the best way to create this type of function, i know syntax is incorrect. Maybe someone can suggest me something
public Item getItem(int id, int position) {
if (id != null) {
for (Item x : items) {
if (x.getId() == id) {
return x;
}
}
} else {
for (int i = 0; i< items.size(); i++) {
return items.get()
}
}
}