Java 如何转换集合<;X>;通过lambda表达式指向对象[]
有没有办法将集合转换为对象数组,通过lambda表达式填充X的成员Java 如何转换集合<;X>;通过lambda表达式指向对象[],java,lambda,java-8,Java,Lambda,Java 8,有没有办法将集合转换为对象数组,通过lambda表达式填充X的成员 Object[{Collection.size}][{X.a},{X.b}] 我需要的是 collection.stream() .filter(o->o.use()) .<insert inner convertion to Object[] {o.getA(), o.getB()} here> .toArray() collection.str
Object[{Collection.size}][{X.a},{X.b}]
我需要的是
collection.stream()
.filter(o->o.use())
.<insert inner convertion to Object[] {o.getA(), o.getB()} here>
.toArray()
collection.stream()
.filter(o->o.use())
.
.toArray()
你差点就拿到了
collection.stream()
.filter(o->o.use())
.map (o-> new Object[] {o.getA(), o.getB()})
.toArray();
.map(o->newobject[]{o.getA(),o.getB()})
。