dcsimg

When did Strings start caching their hash codes?

John Zukowski

Starting with the 1.3 release of Java, the java.lang.String class will only calculate the hashcode once, when its first needed. Future calls to hashCode() will return the previously calculated value.