Guava 的 Iterables.any() 编译时错误
我收到以下代码的错误:
Iterables.any(Lists.<String>newArrayList(), new Predicate<String>() {
@Override
public boolean apply(final String arg0) {
// TODO Auto-generated method stub
return false;
}
});
错误:
类型中的方法any(
Iterable
) Iterables 不适用于参数 (, Predicate ArrayList
, new 谓词
)(){}
我做错了什么?我觉得我犯了一个愚蠢的错误。
I'm getting an error for the following code:
Iterables.any(Lists.<String>newArrayList(), new Predicate<String>() {
@Override
public boolean apply(final String arg0) {
// TODO Auto-generated method stub
return false;
}
});
The error:
The method any(
Iterable<T>, Predicate<? super T>
) in the type
Iterables is not applicable for the arguments (ArrayList<String>, new
Predicate<String>(){}
)
What am I doing wrong? I feel like I'm making a silly mistake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

哎呀 - 我使用了错误的导入。
正确:
错误:
使用
重新打包
Guava 会导致问题。Oops - I was using the wrong import.
Correct:
Incorrect:
Using the
repackaged
Guava leads to problems.