更新时间:2023-10-05 16:12:34
一种方法是获取第一个列表的名称,然后调用allMatch
并进行检查.
One way is to get the name of the first list and call allMatch
and check against that.
String firstName = yourListOfAs.get(0).name;
boolean allSameName = yourListOfAs.stream().allMatch(x -> x.name.equals(firstName));