You cannot do this with indexOf. Instead, all objects in the list should inherit from a common interface - for example,
interface HasIdNum {
String getIdNum();
}
List<HasIdNum>, , id, :
for (HasIdNum hid: objList) {
if (hid.getIdNum().equals(idNumToFind) {
return hid;
}
}
return null;
, :
for (int i=0;i<objList.size();i++) {
HasIdNum hid = objList.get(i);
if (hid.getIdNum().equals(idNumToFind) {
return i;
}
}
return -1;
, , .