Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
I am trying to implement a hashCode method to return the last few chars of a word or number inputted using my JUnit test. Here is my current method:
@Override
public int hashCode(String value){
String test = value;
int hash = 1;
int len = test.length();
System.out.println(len);
for ( int i=0; i<len; i++ )
{
hash = 31 * hash + len;
}
return hash;
}On my test results I get a failure saying it expected a and got an int (98727). Can anyone help me write a hashCode method that returns that last two chars of a word or int? Any help would be most appreciated.