src/share/classes/java/lang/String.java

Print this page

        

@@ -1490,11 +1490,11 @@
      *
      * @return  a hash code value for this object.
      */
     public int hashCode() {
         int h = hash;
-        if (h == 0) {
+        if (h == 0 && count > 0) {
             int off = offset;
             char val[] = value;
             int len = count;
 
             for (int i = 0; i < len; i++) {