Set<Category>tempSet=new HashSet<Category>(baseCategoryList);
Category[] temp=tempSet.toArray(new Category[tempSet.size()]);
baseCategoryList=Arrays.asList(temp);
List baseList=new ArrayList();
public boolean equals(Object o) {
AttributeItemBean s = (AttributeItemBean) o;
if (s.getName().equals(name) && s.getAttrId().equals(attrId)) {
return true;
} else {
return false;
}
}
public int hashCode() {
int result = 17;
result = 37 * result + name.hashCode();
result = 37 * result + attrId.intValue();
return result;
}
private void populateAvailableAttributeGroups(){
availableAttributeGroups = new ArrayList<AttributeGroupBean>(allAttributeGroups);
if(!selectedAttributeGroups.isEmpty()){
availableAttributeGroups.removeAll(selectedAttributeGroups);
}
}
Category[] temp=tempSet.toArray(new Category[tempSet.size()]);
baseCategoryList=Arrays.asList(temp);
List baseList=new ArrayList();
public boolean equals(Object o) {
AttributeItemBean s = (AttributeItemBean) o;
if (s.getName().equals(name) && s.getAttrId().equals(attrId)) {
return true;
} else {
return false;
}
}
public int hashCode() {
int result = 17;
result = 37 * result + name.hashCode();
result = 37 * result + attrId.intValue();
return result;
}
private void populateAvailableAttributeGroups(){
availableAttributeGroups = new ArrayList<AttributeGroupBean>(allAttributeGroups);
if(!selectedAttributeGroups.isEmpty()){
availableAttributeGroups.removeAll(selectedAttributeGroups);
}
}
本文介绍了如何使用Java进行集合操作,包括将集合转换为数组、从一个集合中移除另一个集合中存在的元素等。同时,还展示了自定义对象的equals方法和hashCode方法的实现方式,以确保对象比较的一致性和正确性。
3913

被折叠的 条评论
为什么被折叠?



