1. 利用 Java8特性 list stream方式
import java.util.stream.Collectors;
List<entity> list;
List<Integer> ids = list.stream().map(entity::getId).collect(Collectors.toList());
2.CollectionUtils
import org.springframework.cglib.core.CollectionUtils;
List<Map> classList;
List<String> classIds = CollectionUtils.transform(classList, map -> ((Map) map).get("classId"));
转载自:https://blog.csdn.net/zhaoyajie1011/article/details/105935291