Community
Participate
Working Groups
The documentation of the equals method from object states that comparisons must be per semantic value. array.equals compares per reference value. The following code does not act consistently int[] rba, vba; .... vba.equals(rba)) --> false; Nevertheless this test is succesfull: assertEquals(vba.length, rba.length); for (int i = 0; i < rba.length; i++) { assertEquals(vba[i],rba[i]); }
This is a language spec issue, nothing to do with our compiler. Object#equals is implemented as an identity check, and clients may refine it to be more tolerant (i.e. compare held values instead). array #equals is spec'ed to use the Object method implementation. Please complain against the owner of the language spec, we have to comply.