Java AbstractCollection 类的 remove() 方法
如果要从AbstractCollection类中删除元素,请使用该remove()方法。如果请求删除的元素已成功从集合中删除,则返回TRUE。
语法如下:
public boolean remove(Object ob)
这里,ob是要从此集合中删除的元素。而类Object是类层次结构的根。
要在Java中使用AbstractCollection类,请导入以下包:
import java.util.AbstractCollection;
以下是remove()在Java中实现AbstractCollection方法的示例:
示例
import java.util.Iterator; import java.util.ArrayList; import java.util.AbstractCollection; public class Demo { public static void main(String[] args) { AbstractCollection输出结果
AbstractCollection = [Laptop, Tablet, Mobile, E-Book Reader, SSD, HDD] Collection after removing some elements = [Laptop, Mobile, E-Book Reader, HDD]