Java Set. Remove() method: removes the specified object from the set collection
•
Java
remove(Object o)
Typical application
public static void main(String[] args){ Set set = new HashSet(); //定义Set对象 set.add("apple"); //向集合中添加对象 set.add("配置优良的计算机"); set.add("book"); System.out.println("Set大小为:"+set.size()); //输出集合大小 set.remove("book"); //移除集合元素 System.out.println("从Set集合移除了\"book\""); System.out.println("Set大小为:"+set.size()); }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码