给定,
Stream<String>您可以将每个项目解析为,
int并将其包装为
Object[]使用:
strings .filter(s -> s.trim().length() > 0) .map(Integer::parseInt) .map(i -> new Object[]{i})现在要将结果转换为a,
Object[][]您只需执行以下操作:
Object[][] result = strings .filter(s -> s.trim().length() > 0) .map(Integer::parseInt) .map(i -> new Object[]{i}) .toArray(Object[][]::new);对于输入:
final Stream<String> strings = Stream.of("1000", "999", "745", "123");输出:
[[1000], [999], [745], [123]]



