import java.util.ArrayList; import java.util.Collection; public class Collection_remove { public static void main(String[] args) { Collection c = new ArrayList(); c.add(new Point(1,2)); c.add(new Point(2,3)); c.add(new Point(3,4)); c.add(new Point(2,3)); System.out.println(c); Point p = new Point(2,3); /** * boolean remove(E e) * 从集合中删除与指定元素equals比较为true的元素 * 需要注意,只会删除一个,集合会顺序进行比较,删除第一个equals比较为true的元素后停止删除 */ c.remove(p); System.out.println(c); } }