Java Hash String hashCode(String s)

Here you can find the source of hashCode(String s)

Description

hash Code

License

Open Source License

Declaration

public static long hashCode(String s) 

Method Source Code

//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;
    }
}

Related

  1. hash32(String data)
  2. hashAlgToId(String hashAlg)
  3. hashArrayToString(int a[])
  4. hashbang(final String historyToken)
  5. hashcode(String name)
  6. hashCode(String sIn)
  7. hashCode(String str)
  8. hashCode1(String str)
  9. hashCode2(String str)