对象数组的转化

1.根据对象数组中的某一个属性进行数组排序

Collections.sort(pointList, new Comparator<Point>(){
@Override
public int compare(Point p1, Point p2) {
//排序属性
if(p1.getXCoordinate() <=p2.getXCoordinate()){
return 1;
}
return -1;
}
});

 

2.根据对象的集合获取属性的集合

ObjectList.stream().map(Meter ::getId).collect(Collectors.toList())

posted @ 2020-07-02 14:46  超超小仙女  阅读(158)  评论(0编辑  收藏  举报