Arrays don't override equals
, so you get reference equality - that's why your System.out.println
call is printing false
. However, JUnit's method is asserting that the arrays are logically equal, i.e. that they're the same size, and each element pair within them is equal. That's almost always what you want when you're writing a test involving arrays.
I suspect Kent wrote the bit of that book before JUnit had this useful behaviour, however. (Indeed, I expect the book predates the overload existing at all.)