stream().sorted(e -> e.getEnterpriseName())
时间: 2024-06-04 19:14:05 浏览: 92
10.第十节-使用stream流sorted实现排序.mp4
This code is incorrect. The correct syntax for sorting a stream based on a specific property is:
stream().sorted(Comparator.comparing(e -> e.getEnterpriseName()))
This code sorts the stream based on the EnterpriseName property in ascending order. If you want to sort in descending order, you can use:
stream().sorted(Comparator.comparing(e -> e.getEnterpriseName(), Comparator.reverseOrder()))
阅读全文