There are 3 by 3 matrices:
[0, 0, 1] [0, 1, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0] ... ... ... I need to go through all such matrices and determine the matrices for which the sum of rows / columns / diagonals coincide. Decided to do through reduce:
List<Object[]> resolvedMatrices = matrices.stream().reduce((a, b) -> { Object temp = new Object(); if(a[0][0] + a[0][1] + a[0][2] == b[0][0] + b[0][1] + b[0][2]) { temp = new Object[]{a, b}; } return temp; }); But something kind of garbage I get:
bad return type in lambda expression: Object cannot be converted to int [] [];
What am I doing wrong?
UPD:
Changed data types.
List<int[][]> resolvedMatrices = matrices.stream().reduce((a, b) -> { int[][] temp = {}; if(a[0][0] + a[0][1] + a[0][2] == b[0][0] + b[0][1] + b[0][2]) { temp = new int[a][b]; // ?????? } return temp; });
int[][]anywhere. - JamesJGoodwinList<int[][]> matrices- JamesJGoodwin