public String printSpiral()
    {
        StringBuilder sb = new StringBuilder();
        int rmid = mat.length / 2;
        if (mat.length % 2 != 0) {
            rmid++;
        }
        for (int xx = 0; xx < rmid; xx++) {
            for (int col = xx; col < mat[0].length - xx; col++) {
                if (col != 0) {
                    sb.append(", ");
                }
                sb.append(mat[xx][col].toString());
            }
            for (int row = xx + 1; row < mat.length - xx - 1; row++) {
                sb.append(", ");
                sb.append(mat[row][mat[0].length - xx - 1].toString());
            }
            if (mat.length - xx - 1 > xx) {
                for (int col = mat[0].length - xx - 1; col >= xx; col--) {
                    sb.append(", ");
                    sb.append(mat[mat.length - xx - 1][col].toString());
                }
            }
            if (mat[0].length - xx - 1 > xx) {
                for (int row = mat.length - xx - 2; row > xx; row--) {
                    sb.append(", ");
                    sb.append(mat[row][xx].toString());
                }
            }
        }
        return sb.toString();
    }