考虑以下代码
String[] colours1 = new String[]{"red", "green", "blue"};
String[] colours2 = new String[]{"red", "yellow", "blue"};
String[] colours3 = new String[]{"red", "green", "blue"};
List<String[]> distinct = Stream.of(colours1, colours2, colours3)
.distinct() // Do something here to compare arrays better
.collect(Collectors.toList());
我希望“distinct”列表只包含两个元素“colours1”和“colours2”(因为1和3是等效的)。但是由于流“distinct()”方法执行相等比较,它仍然包含所有3种颜色数组。我想要一个自定义的distinct功能,可以提供一个比较器。在这种情况下,“Objects#deepEquals”就足够了。有简单的方法来实现这个吗?