Here you can find the source of hashCode(String s)
public static long hashCode(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static long hashCode(String s) { long returnValue = hashCode(s, 31); return returnValue; }//from w ww.ja v a 2s .co m public static long hashCode(String s, int i) { int returnValue = 0; char[] charArray = new char[s.length()]; s.getChars(0, s.length(), charArray, 0); for (int n = 0; n < s.length(); n++) { char charTemp = charArray[n]; returnValue += charTemp * Math.pow(i, s.length() - (n + 1)); } return returnValue; } }