java - How to remove an object from a list -
in java, can remove object list using method list.remove(object o), method uses equals method of object identify element in list. but, requires override equals method(otherwise default implementation of equals method used, involves comparing references). if dealing list of objects , developer doesn't have liberty change source code of object implement equals method, can do? wondering why java has not provided method list.remove(object o, comparator c), because remove object based on custom equality condition(implemented comparator), solutions problem?
if want more complicated, can iterate yourself, performing comparisons want, , use list.remove(int)
remove index.
Comments
Post a Comment