(四)数组扁平化

public static int[] deepFlatten(Object[] input) {
    return Arrays.stream(input)
            .flatMapToInt(o -> {
                if (o instanceof Object[]) {
                    return Arrays.stream(deepFlatten((Object[]) o));
                }
                return IntStream.of((Integer) o);
            }).toArray();
}

 

posted @ 2018-02-03 01:43  R4mble  阅读(113)  评论(0编辑  收藏  举报