Java中的可过滤集合
|
是否有提供过滤方法的Java集合类?我对Java有点陌生,因此浏览所有集合类以及它们与接口交织的所有微妙方式都有些混乱。我想要的是一个收集类,它执行以下操作:
FilterableCollection<SomeClass> collection = new FilterableCollection<SomeClass>();
// add some elements to the collection
// filter the collection and only keep certain elements
FilterableCollection<SomeClass> filtered_collection = collection.filter(
new Filter<SomeClass>() {
@Override
public boolean test(SomeClass obj) {
// determine whether obj passes the test or not
}
}
);
没有找到相关结果
已邀请:
2 个回复
闪票仇门韧
缮淳彼誊
您可以使用函数库,但是在Java中,这些函数库几乎总是会使代码变得更复杂。 Java不能很好地支持这种编程风格。 (将来可能会改变)