When and why does List remove(Object object) return false

后端 未结 3 1938
情歌与酒
情歌与酒 2020-12-19 21:27

When and why does the method boolean java.util.List.remove(Object object) return false?

The documentation states

[The method ret

3条回答
  •  失恋的感觉
    2020-12-19 21:57

    from this doc

    Removes the first occurrence of the specified element from this list, if it is present (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).

提交回复
热议问题