这与
Collections.sort()对参数引用进行排序的地方不同。在这种情况下,您将得到一个排序后的流,最终需要将其收集并分配给另一个变量:
List result = list.stream().sorted((o1, o2)->o1.getItem().getValue(). compareTo(o2.getItem().getValue())). collect(Collectors.toList());
您只是错过了分配结果
欢迎分享,转载请注明来源:内存溢出
这与
Collections.sort()对参数引用进行排序的地方不同。在这种情况下,您将得到一个排序后的流,最终需要将其收集并分配给另一个变量:
List result = list.stream().sorted((o1, o2)->o1.getItem().getValue(). compareTo(o2.getItem().getValue())). collect(Collectors.toList());
您只是错过了分配结果
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)