Why is java solution much faster than C++ solution

For toeplitz matrix/problem 766.
Following solution

    public boolean isToeplitzMatrix(int[][] matrix) {
        for (int r = 0; r < matrix.length; ++r)
            for (int c = 0; c < matrix[0].length; ++c)
                if (r > 0 && c > 0 && matrix[r-1][c-1] != matrix[r][c])
                    return false;
        return true;
    }
}```
Java solution runs in 1 ms and the C++ equivalent code in 23 ms.
Any idea why this might be the case?
Comments (1)