您的当前位置:首页正文

JAVA中List的remove(Objectobj)方法

2021-05-08 来源:布克知识网
JAVA中List的remove(Objectobj)⽅法

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 anelement exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).删除第⼀个出现的相同对象,判断时,需要使⽤equals⽅法,如果是⾃⼰创建的对象,需要重写类的hashCode和equals⽅法

因篇幅问题不能全部显示,请点此查看更多更全内容

Top