Eamonn McManus wrote:
Joseph D. Darcy wrote:
> What are scenarios where this method would be used?
I use a similar method fairly often in unit tests. JUnit's
assertEquals doesn't
do the right thing if its arguments happen to be arrays, so I use the
following
simple if inefficient implementation:
static void deepEquals(Object x, Object y) {
return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
}
What that shows of course is that the messy logic you mention is
already present in
Arrays.deepEquals so you could factor it out.
Yes, the logic inside the for loop in deepEquals could be factored out
into just the right package-private helper method.
Thanks for the pointer!
-Joe