public void printSumOfAllSquareMatrix(int input[][]){
        
        for(int len = 1; len <= input.length; len++){
            for(int i=0; i < input.length - len + 1; i++){
                for(int j=0; j < input[i].length - len + 1; j++){
                    int sum = 0;
                    for(int k=i;k < i+len; k++){
                        for(int m = j; m < j+len; m++){
                            sum += input[k][m];
                        }
                    }
                    System.out.println("Start " + i + " " + j + " End " + len + " sum " + sum);
                }
            }
        }
    }
Iterate through matrix and get all subsquare and subrectangle matrix and print their sum
src/com/interview/multiarray/MatrixFindAllSubSquareRectangleMatrix.java