public Class Test{ //获取list集合中单个属性:比如获取id List<Object> list = new ArrayList<>(); List<Integer> ids = list.stream().map(Object::getId).collect(Collectors.toList()); //foreach循环获取 List<Integer> ids2 = new ArrayList<>(); list.stream().forEach(i -> { int a = i.getId(); ids.add(a); String b = i.getName(); } }