在对象里面重写两个方法就可以了
public class Fztj extends Identifiable{
private static final long serialVersionUID = 5380979414822611344L;
private String rydm;
private String sj;
public String getRydm() {
return rydm;
}
public void setRydm(String rydm) {
this.rydm = rydm;
}
public String getSj() {
return sj;
}
public void setSj(String sj) {
this.sj = sj;
}
/**
* set<>去重,重写如下两个方法hashCode、equals
*/
@Override
public int hashCode(){
return rydm.hashCode();
}
@Override
public boolean equals(Object obj){
if(obj instanceof Fztj){
Fztj fztj=(Fztj)obj;
return (rydm.equals(fztj.getRydm())&&sj.equals(fztj.getSj()));
}
return super.equals(obj);
}
}