hashcode

Discussion in 'Java' started by gk, Sep 15, 2006.

  1. gk

    gk Guest

    public int hashCode()

    Returns a hash code for this string. The hash code for a String
    object is computed as

    s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]



    How this value is calculated ?

    say i have String s="abc"

    so ,

    s[0]= a
    s[1]=b
    s[2]=c

    but how do i get the power of a character ?

    say the first term ...
    a*31^2 = whats this ? whats the neumerial value of it ?
     
    gk, Sep 15, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roedy Green

    hashCode for byte[]

    Roedy Green, Aug 22, 2003, in forum: Java
    Replies:
    1
    Views:
    424
    Dale King
    Aug 22, 2003
  2. Marco
    Replies:
    10
    Views:
    771
  3. Gregory A. Swarthout

    equals and hashCode

    Gregory A. Swarthout, Dec 19, 2003, in forum: Java
    Replies:
    2
    Views:
    356
    Silvio Bierman
    Dec 20, 2003
  4. kelvSYC

    Designing hashCode() methods

    kelvSYC, Dec 23, 2003, in forum: Java
    Replies:
    1
    Views:
    378
    Ulrich Stern
    Dec 24, 2003
  5. Dimitri Pissarenko

    Hashcode of primitive types

    Dimitri Pissarenko, Jan 29, 2004, in forum: Java
    Replies:
    5
    Views:
    5,860
    Hylander
    Jan 29, 2004
Loading...

Share This Page