deepEquals and equals
Hello,
pls can anyone tell me the difference between Arrays' deepEquals and equals method? Checked Java API, couldn't see any difference.
Thanks.
Hello,
pls can anyone tell me the difference between Arrays' deepEquals and equals method? Checked Java API, couldn't see any difference.
Thanks.
That's strange. When I looked, the entry for deepEquals() was much longer than the entry for equals().
So you're saying the difference in the methods is that one has a longer API entry?
;-)
import java.util.*;
public class DeepEqualsExample {
public static void main(String[] args) {
int[] a = {1, 2};
int[] b = {1, 2};
int[][] aa = {a};
int[][] bb = {b};
System.out.println("Arrays.equals(aa,bb)=" + Arrays.equals(aa,bb));
System.out.println("Arrays.deepEquals(aa,bb)=" + Arrays.deepEquals(aa,bb));
}
}
always helps to read everything
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#deepEquals(java.lang.Object[],%20java.lang.Object[])
Well, thanks everyone especially, bigDaddyLoveHandles. Ur suggestions are very helpful. I understand now.
Thanx
> So you're saying the difference in the methods is
> that one has a longer API entry?
No, I'm making the trivial observation that if the entries have different lengths then they cannot be the same. And hence anybody who thought they were the same should look again.