如何显示结果React
我尝试:
shallow
答案 0 :(得分:3)
您应该使用Arrays.toString
来打印数组:
stream.forEach(ints -> System.out.println(Arrays.toString(ints)));
答案 1 :(得分:2)
查看此行:
Stream<int[]> allResults = list.stream();
这意味着,流的每个元素都是一个数组,您可以这样做:
allResults.flatMap(a -> Arrays.stream(a).mapToObj(Integer::valueOf)).forEach(System.out::println);
或者,就像@YCF_L所建议的那样,甚至更简单:
allResults.flatMap(Stream::of).forEach(System.out::println);
答案 2 :(得分:1)
好吧,您可以执行以下操作:
int[] numbers = {2,4,7,4,3,6};
IntStream.of(numbers).forEach(System.out::print);
更新:
如果您像某些建议一样具有int [] [],请使用以下代码:
int[][] numbersOfNumbers = {{1, 25, 63}, {4}, {42, 53},{3,6,4,7,3}};
//same as above with int[][]
Stream.of(numbersOfNumbers).flatMap(Stream::of).forEach(i->IntStream.of(i).forEach(System.out::print));
Stream.of(numbersOfNumbers).flatMap(Stream::of).forEach(numbs->System.out.println(Arrays.toString(numbs)));