How to check a 2D matrix is empty?

Viewed 5947

I think that all we need is

if (matrix.length == 0)

However, I saw some of them write

if (matrix == null || matrix.length == 0 || matrix[0].length == 0) 

Is my version enough to check a matrix is empty or not or we need to write the above version?

1 Answers
Related