我在尝试编译时遇到此错误:
filter(Iterable<T>, Predicate<? super T>)类型Iterables中的方法不适用于参数(Iterator<PeopleSoftBalance>, ColumnLikePredicate<PeopleSoftBalance>)
这是ColumnLikePredicate类的sig:
public class ColumnLikePredicate<T extends RowModel> implements Predicate<T>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
mat*_*t b 14
听起来你正在传递一个Iterator期望的方法Iterable.
迭代器:
集合上的迭代器
可迭代:
实现此接口允许对象成为"foreach"语句的目标.
Iterator是一个可用于迭代(不同)集合的对象.Iterable是一个可以迭代的对象.
我猜你有某种类型,collection而你正在调用类似的东西Iterables.filter(collection.iterator(), predicate).该Iterables课程希望您传递Iterable本身,例如:
Iterables.filter(collection, predicate)
Run Code Online (Sandbox Code Playgroud)