When you call remove(object o) on an arraylist, how does it compare objects?

前端 未结 4 1865
借酒劲吻你
借酒劲吻你 2020-12-06 09:13

When you call remove(object o) on an arraylist in java, how does it compare the objects to find the correct one to remove? does it use the pointer? or does it compare the ob

4条回答
  •  借酒劲吻你
    2020-12-06 09:42

    The docs answer your question:

    Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if the collection contains one or more such elements.

提交回复
热议问题