jdk Sdiff src/java.base/share/classes/java/lang (original) (raw)


1434 / 1435 public boolean endsWith(String suffix) { 1436 return startsWith(suffix, value.length - suffix.value.length); 1437 } 1438 1439 /* 1440 * Returns a hash code for this string. The hash code for a 1441 * {@code String} object is computed as 1442 *

1443      * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
1444      * 
1445 * using {@code int} arithmetic, where {@code s[i]} is the 1446 * ith character of the string, {@code n} is the length of 1447 * the string, and {@code ^} indicates exponentiation. 1448 * (The hash value of the empty string is zero.) 1449 * 1450 * @return a hash code value for this object. 1451 */ 1452 public int hashCode() { 1453 int h = hash; 1454 if (h == 0 && value.length > 0) { 1455 char val[] = value; 1456 1457 for (int i = 0; i < value.length; i++) { 1458 h = 31 * h + val[i]; 1459 } 1460 hash = h; 1461 } 1462 return h; 1463 } 1464 1465 /** 1466 * Returns the index within this string of the first occurrence of 1467 * the specified character. If a character with value 1468 * {@code ch} occurs in the character sequence represented by 1469 * this {@code String} object, then the index (in Unicode 1470 * code units) of the first such occurrence is returned. For 1471 * values of {@code ch} in the range from 0 to 0xFFFF 1472 * (inclusive), this is the smallest value k such that: 1473 *
1474      * this.charAt(k) == ch
1475      * 
1476 * is true. For other values of {@code ch}, it is the 1477 * smallest value k such that: 1478 *



1434 / 1435 public boolean endsWith(String suffix) { 1436 return startsWith(suffix, value.length - suffix.value.length); 1437 } 1438 1439 /* 1440 * Returns a hash code for this string. The hash code for a 1441 * {@code String} object is computed as 1442 *

1443      * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
1444      * 
1445 * using {@code int} arithmetic, where {@code s[i]} is the 1446 * ith character of the string, {@code n} is the length of 1447 * the string, and {@code ^} indicates exponentiation. 1448 * (The hash value of the empty string is zero.) 1449 * 1450 * @return a hash code value for this object. 1451 */ 1452 public int hashCode() { 1453 int h = hash; 1454 if (h == 0) { 1455 for (int v : value) { 1456 h = 31 * h + v;

1457 } 1458 hash = h; 1459 } 1460 return h; 1461 } 1462 1463 /** 1464 * Returns the index within this string of the first occurrence of 1465 * the specified character. If a character with value 1466 * {@code ch} occurs in the character sequence represented by 1467 * this {@code String} object, then the index (in Unicode 1468 * code units) of the first such occurrence is returned. For 1469 * values of {@code ch} in the range from 0 to 0xFFFF 1470 * (inclusive), this is the smallest value k such that: 1471 *

1472      * this.charAt(k) == ch
1473      * 
1474 * is true. For other values of {@code ch}, it is the 1475 * smallest value k such that: 1476 *