Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Help comparing two arrays
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Patricia Shanahan, post: 619765"] int i[][] is not an array of int. It is an array of references to arrays of int, so you were looking at the wrong part of the documentation. To compare, for example, i[0] to j[0], Arrays.equals will use (i[0]==null ? j[0]==null : i[0].equals(j[0])), which is false unless i[0] and j[0] are either both null or are references to the same object. A lot of Java books confuse two different concepts: 1. Arrays of array references, which Java does have. 2. Multidimensional arrays, which it does not have and for which arrays of array references are a rough approximation. If i and j were two-dimensional arrays of int, they would have the same size, and the same elements, in the same order, so they should be equal. They are not equal because they are really arrays of references to different arrays of int. Patricia [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Help comparing two arrays
Top