我在尝试编译时遇到此错误:
方法filter(Iterable<T>, Predicate<? super T>)
Iterables 类型不适用于参数(Iterator<PeopleSoftBalance>, ColumnLikePredicate<PeopleSoftBalance>
)
这是 ColumnLikePredicate 类 sig:
public class ColumnLikePredicate<T extends RowModel> implements Predicate<T>
我做错了什么?
最佳答案
听起来您正在将 Iterator
传递给需要 Iterable
的方法。
Iterator :
An iterator over a collection
Iterable :
Implementing this interface allows an object to be the target of the "foreach" statement.
Iterator
是一个可用于迭代(不同的)集合的对象。 Iterable
是一个可以迭代的对象。
我猜你有某种 collection
并且你正在调用类似 Iterables.filter(collection.iterator(), predicate)
的东西。 Iterables
类希望您传递 Iterable 本身,例如:
Iterables.filter(collection, predicate)
关于java - Google Guava 和一个我无法弄清楚的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3454829/