The answer is 1026. How did you come up with this answer Dan ?
SCJP 1.4
Maria Garcia
Ranch Hand
Joined: Jul 14, 2002
Posts: 86
posted
0
oops!! i made a boo-boo... I got it now.
Ray Chang
Greenhorn
Joined: Sep 10, 2002
Posts: 25
posted
0
Can you explain? thank you.
Dan Chisholm
Ranch Hand
Joined: Jul 02, 2002
Posts: 1865
posted
0
Originally posted by Ray Chang: Can you explain? thank you.
If you would like to know how the hash code is calculated then just move the print statement into the hashCode method.
A good hashcode calculation for an array will use the value of each element of the array. An even better hashcode method for an array will also depend on the position of each value in the array. The following is an example of a hashcode method that does not produce unique hashcodes for arrays that contain the same set of elements in different orders.
The result is "6,6,6". A better hashCode method produces unique values when the position of the array elements is changed.
The result is "1026,2016,2946".
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Barkat Mardhani
Ranch Hand
Joined: Aug 05, 2002
Posts: 787
posted
0
Hi Dan: I am trying to find an easy read on HashCode() method. Can you suggest one?