如何将Java8流用于此代码:
this.img = this.images[1];
使用流:
Specification<T> specification = specifications.getSpec(searchCriteria.getConditions().get(0));
for(int i = 1; i < searchCriteria.getConditions().size(); i++) {
specification = specification.and(getSpec(searchCriteria.getConditions().get(i)));
}
相关的类和方法:
IntStream.range(1,searchCriteria.getConditions().size())
.mapToObj(index-> getSpec(searchCriteria.getConditions().get(index)))
.collect();//how to merge with calling and
答案 0 :(得分:4)
如果我正确理解:
num in range(0,6)
甚至更好:
lst = []
for num in range(0,6):
lst.append(num)
print(lst) # Un-indent :D