更新时间:2023-10-05 16:16: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));