Set的最大特点是能去掉重复的元素并获取相应数据下面看个简单的代码先使用QBC查询出所有员工在过滤掉重复的员工所在部门最后得到所有员工的部门串
view plain List<Employee> list = employeeDAOfindByExample(employee)Set set = new HashSet()for (int i = i < listsize() i++) { setadd(listget(i)getDepartmentId())} String deptIds = Iterator it = erator()while (ithasNext()) { deptIds = + itnext()toString() + }