package practice;
import java.util.HashSet;import java.util.Set;
public class T2 {public static void main(String[] args) {Set<Cell> set = new HashSet<Cell>();Cell c1 = new Cell(1,2);Cell c2 = new Cell(3,2);set.add(c1);set.add(c2);c2 .x = 1;System.out.println(c2.equals(c1));System.out.println(set.remove(c1));System.out.println(set.remove(c2));System.out.println(set);System.out.println(set.contains(new Cell(1,2)));}}
class Cell {int x;int y;
public Cell(int x, int y) {this.x = x;this.y = y;}@Overridepublic boolean equals(Object obj) {System.out.println("AAAAA");return x == ((Cell) obj).x && y == ((Cell) obj).y;}@Overridepublic int hashCode() {return x * 1000 + y;}@Overridepublic String toString() {return x + ":" + y;}}

为什么删不了set中的(1,2),想的头都大了,救命啊
import java.util.HashSet;import java.util.Set;
public class T2 {public static void main(String[] args) {Set<Cell> set = new HashSet<Cell>();Cell c1 = new Cell(1,2);Cell c2 = new Cell(3,2);set.add(c1);set.add(c2);c2 .x = 1;System.out.println(c2.equals(c1));System.out.println(set.remove(c1));System.out.println(set.remove(c2));System.out.println(set);System.out.println(set.contains(new Cell(1,2)));}}
class Cell {int x;int y;
public Cell(int x, int y) {this.x = x;this.y = y;}@Overridepublic boolean equals(Object obj) {System.out.println("AAAAA");return x == ((Cell) obj).x && y == ((Cell) obj).y;}@Overridepublic int hashCode() {return x * 1000 + y;}@Overridepublic String toString() {return x + ":" + y;}}

为什么删不了set中的(1,2),想的头都大了,救命啊