jdk/src/java.base/share/classes/java/lang/String.java
changeset 41219 eab7a5086e95
parent 38786 8e7b0ac05815
child 44369 b5c4e28a7521
equal deleted inserted replaced
41218:c22c646e063c 41219:eab7a5086e95
  1514      * (The hash value of the empty string is zero.)
  1514      * (The hash value of the empty string is zero.)
  1515      *
  1515      *
  1516      * @return  a hash code value for this object.
  1516      * @return  a hash code value for this object.
  1517      */
  1517      */
  1518     public int hashCode() {
  1518     public int hashCode() {
  1519         if (hash == 0 && value.length > 0) {
  1519         int h = hash;
  1520             hash = isLatin1() ? StringLatin1.hashCode(value)
  1520         if (h == 0 && value.length > 0) {
  1521                               : StringUTF16.hashCode(value);
  1521             hash = h = isLatin1() ? StringLatin1.hashCode(value)
  1522         }
  1522                                   : StringUTF16.hashCode(value);
  1523         return hash;
  1523         }
       
  1524         return h;
  1524     }
  1525     }
  1525 
  1526 
  1526     /**
  1527     /**
  1527      * Returns the index within this string of the first occurrence of
  1528      * Returns the index within this string of the first occurrence of
  1528      * the specified character. If a character with value
  1529      * the specified character. If a character with value