我实际上想将其替换为方法引用,因为声纳引发了问题,我也搜索了类似标题的答案,但我无法找到解决方案。
String type="test2"
List<String> validSimtSwType = Arrays.asList("test1", "test2", "test3", "test4");
if((validSimtSwType.stream().anyMatch(name -> type.contains(name)))){
//statements
}
最佳答案
您可以将其替换为引用 type
实例的 contains
方法的方法引用:
if((validSimtSwType.stream().anyMatch(type::contains)))
关于java - 将 lambda 替换为 contains 的方法引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53189315/