Does anybody know a reliable hashCode-function for strings?

Hello,
I would like to exchange hashcodes between clients and server, both running at different jre's (even msjvms are running it) - and for the same string they should be identical.
Javadoc mentions that Object.hashCode() may vary from imlpementation, but I would need an implementation which would be consistent across jvms.
Does anybody know a reliable function which does compute a integer-hash-value out of string?
Reliable means that its quite unlikely that two different strings get the same hash-value (although I know this cannot be guaranteed 100%).
Thanks in advance, lg Clemens

Even the hashcode() API points out that
it is just a suggestion that it returns the memory
address of an object, an implementation that might
differ from other JVMs. So if you'd rely on that
behaviour, you'd need to check JVM vendors as well.True, and that is why you shouldn't rely on the fact that Object.hashCode returns the memory address, but I think it's safe to rely on the fact that String.hashCode returns the same hashCode on all platforms (if they are using the same Java version).
The javadoc for String.hashCode says:
     * Returns a hash code for this string. The hash code for a
     * <code>String</code> object is computed as
     * <blockquote><pre>
     * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
     * </pre></blockquote>
     * using <code>int</code> arithmetic, where <code>s</code> is the
* <i>i</i>th character of the string, <code>n</code> is the length of
* the string, and <code>^</code> indicates exponentiation.
* (The hash value of the empty string is zero.)
* @return a hash code value for this object.
So that contract must be fulfilled by all implementations.
Kaj

Similar Messages

  • Does anybody know how to write GUI for J2ME?

    Does anybody know how to write GUI for J2ME?
    Thanks!

    Hi..! I don't know exactly... it's a good question. I refered something. U visit below URL's.
    http://www.java-pro.com/upload/free/features/javapro/2000/13iss00/rg0013/rg0013.asp
    http://developer.java.sun.com/developer/technicalArticles/wireless/midpui/

  • Does anybody knows when is the launch for the new iPad retina display 2013?, Does anybody knows when is the launch for the new iPad retina display 2013?

    Does anybody knows when is the launch for the new iPad retina display 2013?

    King_Penguin wrote:
    Nobody on here will know until if/when Apple announce something.
    Ditto

  • Does anybody know of a parametric design plugin for illustrator similar to Grasshopper?

    I have a situation where I would like to make complex parametric transformations to 2D shapes, much like you can do in Grasshopper for Rhino. Does anybody know of such a plugin for Illustrator?
    Thank you for the help!

    You might want to show an example.

  • My control center and notification center are not showing when I swipe in there respective locations. Does anybody know why?

    My control center and notification center are not showing when I swipe in there respective locations. Does anybody know why?

    Thank you for the sugestion, but it was working fine both on the lock screen and on my home screen. I check all my settings and it is how it was from Friday, when I got the iPhone 5s. It just stop working.  The only way I can fix it is by shutting down the phone. It will work for a while, then it won't. 

  • I am looking for an app that can unmute my iphone after a preset time, eg 1 or 2 hours. Does anybody know an app with this feature?? The apps I have found are linked to a calendar or a place, I just need the timer function..

    I am looking for an app that can unmute my iphone after a preset time, eg 1 or 2 hours. Does anybody know an app with this feature?? The apps I have found are linked to a calendar or a place, I just need the timer function..

    thanks. yes i am aware of the VoiceOver feature but it is NOT the solution to my problem. as you said, it is a solution to a different set of issues. i want the text to speech ability because i there are books i need to read but do not have the time to sit down and read them and have become used to listening to them read to me either by a professional human reader or with the text to speech software on the Kindle.
    I think Apple makes the best audio devices but i am really disappointed in this inexplainable shortcoming. if apple can give us siri they ought to be able to design a nice little button that i can push to turn on text to speech while i am in a document, book, magazine or webpage. clearly it is possible as apple has added the "reader" button in safari to have web pages dropped into the reader format.
    thanks for your suggestion though, it is what everyone suggests but it does not address the issue.

  • Does anybody know how to get a scroll bar for a long list of podcasts when selcting some for sync? Thanks

    Does anybody know how to get a scroll bar for a long list of podcasts when selcting some for sync? Thanks

    Hi lbadek
    I can help with this please send us an email using the contact the mods link in my proifle and we will investigated from there.
    Thanks
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • I have 2 iPhones - one for personal use and one for work. They are currently connected with the same Apple ID. I would like to separate the two accounts. Does anybody know how to do this?

    I have 2 iPhones - one for personal use and one for work. They are currently connected with the same Apple ID. I would like to separate the two accounts. Does anybody know how to do this?

    Just create a new AppleID for your work.
    As Allan suggested, items purchased on one iTunes account cannot be moved to the other account.
    However, you can put items purchased on on account onto the other iPhone.

  • Does anybody knows where can i buy a replacement AC power cable for my cinema display 27"?

    Does anybody knows where can i buy a replacement AC power cable for my cinema display 27"?

    It may not be the same molded plug but I would think any normal 3-prong computer power cable should work.
    How about this one?
    922-6529 Power Cord - Apple Cinema Display
    I've always had the theory that if you put two computer power cords in a drawer they will breed and you'll end up with a lot more!   My parts drawer is always full of them.  They like to knot up by themselves as well!  Maybe that's how they breed.

  • Does anybody know if Windows 8 is causing a problem with iTunes?   Many songs on my old iPod are now missing in my iTunes library and I can't find them anywhere.  Also, I have a new iPod and am afraid of using it for fear of something else going wrong.

    Does anybody know if Windows 8 is causing a problem with iTunes?  Many songs on my old iPod are now missing in my iTunes library and I can't find them anywhere.  .  Also, I have a new iPod and am afraid of using it for fear of something else going wrong.

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • Does anybody know table for copy controls from Sales document to Delivery

    Hi,
    Does anybody know table for copy controls from Sales document to Delivery. Especially for item level.
    Regards,
    Praveen

    >
    Lakshmipathi wrote:
    > Almost all members know copy control from sale order to delivery.  What exactly your problem is ??   Please post that and avoid asking questions like this !!!!!!!!!!
    >
    > thanks
    > G. Lakshmipathi
    Sorry for my post. I guess you were a wee bit quicker than me in the reposnse

  • Does anybody know if and when there will be a plug in for raw files from the Nikon D810? I have lightroom 4

    I am considering buying a Nikon D810 but I do not want to be waiting for ages for a plug in for it's RAW files on my Lightroom 4. Does anybody know if and when there will be a plug in? I presume the 8.5 plug in will not cover the cameras Raw file.

    There is no plug-in for Lightroom 4 that would ever give you support for the new camera. Lightroom does not use Camera Raw. Camera Raw is a plug-in for Photoshop and Photoshop Elements. If you want support for your camera in Lightroom you will need to upgrade to Lightroom 5, and then wait for the 5.6 update which should be available within next few weeks (unless Lightroom 6 is introduced). In the meantime you can use the DNG converter (version 8.6 RC) to create DNG copies of your raw images that you would be able to open in Lightroom 4.

  • HT3783 Does anybody know why my calendar in Outlook Office for Mac duplicates and triplicates entries in the calendar?  I would be really grateful for any explanation...  Kind regards Kate

    Does anybody know why my calendar keeps duplicating diary entries in Outlook office for Mac?
    Many thanks in anticipation.
    Kate

    No dont worry i am not going to copy this. The reason i am asking is to see if it is legal or not, its worth getting a discount if its available. Looks like its a no though. If you ask me NUS should be prosecuted because you can be minimum age of 16 and get an NUS card and it says on their site under the link to apple store 'are you a student in further education. If so why not take advantage of a 15% discount on apple products'. (or somethign alogn those lines) Now me and my mate are but we arent over 18. Ive emailed them to try and get a confirmation. Anyone know an email address that i can contact apple directly about this with? Also any more answers to the original post are welcome.
    I would also like to know if i can get any sort of discount on apple products whilst under the age of 18, whether straight through apple or using for example NUS cards.
    Barny
    Message was edited by: barnyiz2cool

  • Does anybody know of a way to get PSX Emulator for iPhone 4s w/ out jailbreak?

    Does anybody know of a way to get PSX Emulator for iPhone 4s (iOS 7) w/ out jailbreak? Im trying to relive my childhood on my phone. I have the gameboy emulator and i know the date and time rule. I was just wondering if anybody knew a good place to get a psx emulator without having to jailbreak my device.
    Also, does anybody on the off chance know a record-your-screen program for iOS 7 without a jailbreak? That would be much appreciated.
    Thank you in advanced,
    PMC~

    I think that the psx emulator is actually in the retroarch emulator.
    Haven't tested it as of yet, because the download link isn't working.
    I'm using the GBA emulator at the moment too but I'm pretty bored of it, I wanted to play final fantasy :(

  • I need a charging power cord for An Apple Newton Model H1000 Does anybody know where I can get one at. It is from 1993.

    Does anybody know where I can get a charging cord for an old Apple Newton model H1000 from 1993?

    Suggest you join LEM-Swap for buying & selling Mac stuff. http://groups.google.com/group/lemswap
    After you join, post a WTB (want to buy).
     Cheers, Tom

Maybe you are looking for

  • Access Control with Custom Groups

    I am rather new to APEX. I am trying to implement access control/authorization using custom groups (not the built-in View, Edit, and Administrator groups). I did search the discussion forums and the web in general but so far I have come up empty. I w

  • Corrupt database, need to start over

    This is a test bed env. I've hosed the .dbf and control files, there's no backup and I don't want to recover. V$DATABASE and V$INSTANCE show the db as intact when I 'startup nomount', but in fact there's no database out there anymore. What I want to

  • Download of latest arrives, can't install

    Can't install the latest version, after it arrives, click to run file it stops. Running Windows Vista [SP2] using Mozilla Firefox.  Keep getting this: " Microsoft Windows Adobe Flash Player 11.7 r700 has stopped working A problem caused the program t

  • Query Designer on Netweaver 2004s ABAP Sneak Preview

    Hello Folks, I have installed the ABAP sneakpreview, and have activated the BW on client 001. Most things work well, but i am having problems with starting the Query Designer. I logon to the query designer, but nothing starts up. In SM50 i see a lot

  • NetBeans Problem with package, pls help.....

    Hi all, I have a package problem. With the following 2 classes, I can compile fine in dos with c:\java> javac WapDev3\*.java but wont compile in Netbeans 3.4 Pls help. The classes are -------------------class sample1 at c:\java\WapDev3---------------