多个list合并
需要多个list合并,如图
@SuppressWarnings("unchecked")
@Override
public List<CwInfo> getCwInfoByParentId(int[] parentIdss) {
List<CwInfo> list = new ArrayList<CwInfo>();
try {
for (int i = 0; i < parentIdss.length; i++) {
List<CwInfo> list2 = jdbcTemplate.query("select * from cw_info where parent_id="+parentIdss[i]+" and is_hidden=1", new cwMapper());
list.addAll(list2); //list.addAll()就是一个两个集合合并
}
return list;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}