QUESTION 2 Consider the following implementation of hashCode(), in a class where str is a String: public int hashCode ()
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
QUESTION 2 Consider the following implementation of hashCode(), in a class where str is a String: public int hashCode ()
QUESTION 2 Consider the following implementation of hashCode(), in a class where str is a String: public int hashCode () { int hash 0; int n str.length; for (int i=0; i<n; i++) { hash 31 * hash + str.charAt(i); } return hash; } If str="try": what does hashCode() return? [a] Note the following ASCII codes: t' is 116 'Tis 114 'Y' is 121
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!