?
-
Please comment on the following and provide a professional alternative
if possible:
public Object getObject(Object object) {
Object obj = null;
// if (object != null) { <---- Qn 1: Should I check for null?
for (Object o : objects) {
if (object.equals(o) { <---- Qn 2: Or if (o.equals(object)) ?
obj = o; If i do this, then I don't
break; need to check for null.
}
}
//}
return obj;
}
if possible:
public Object getObject(Object object) {
Object obj = null;
// if (object != null) { <---- Qn 1: Should I check for null?
for (Object o : objects) {
if (object.equals(o) { <---- Qn 2: Or if (o.equals(object)) ?
obj = o; If i do this, then I don't
break; need to check for null.
}
}
//}
return obj;
}