class Obj {
private String id;
private String name;
getter & setter ...
}
List<Obj> list = new ArrayList<Obj>();
list.add(new Obj("111","xxx"));
... ...
//获取属性为给定值得对象,取其一,无则null
Obj o= res.stream().filter(i -> "111".equals(o.getId())).findAny().orElse(null);
//获取给定对象集合中每个对象指定属性得值构成的集合
List<Double> res = list.stream().map(o -> Double.valueOf(o.getName())).collect(Collectors.toList());
//Double 类型集合取最大值
Double max = res.stream().max(Comparator.comparingDouble(Double::shortValue)).get();
//对给定对象集合,根据集合某属性排重,属性须实现hashCode和equals
List<Obj> list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o-> o.getName()))), ArrayList::new));