src/java.base/share/classes/java/lang/String.java
changeset 50051 f5231f5762fc
parent 49433 b6671a111395
child 50098 92560438d306
equal deleted inserted replaced
50050:0d4920ac269c 50051:f5231f5762fc
  2597     public String toUpperCase() {
  2597     public String toUpperCase() {
  2598         return toUpperCase(Locale.getDefault());
  2598         return toUpperCase(Locale.getDefault());
  2599     }
  2599     }
  2600 
  2600 
  2601     /**
  2601     /**
  2602      * Returns a string whose value is this string, with any leading and trailing
  2602      * Returns a string whose value is this string, with all leading
  2603      * whitespace removed.
  2603      * and trailing space removed, where space is defined
       
  2604      * as any character whose codepoint is less than or equal to
       
  2605      * {@code '\u005Cu0020'} (the space character).
  2604      * <p>
  2606      * <p>
  2605      * If this {@code String} object represents an empty character
  2607      * If this {@code String} object represents an empty character
  2606      * sequence, or the first and last characters of character sequence
  2608      * sequence, or the first and last characters of character sequence
  2607      * represented by this {@code String} object both have codes
  2609      * represented by this {@code String} object both have codes
  2608      * greater than {@code '\u005Cu0020'} (the space character), then a
  2610      * that are not space (as defined above), then a
  2609      * reference to this {@code String} object is returned.
  2611      * reference to this {@code String} object is returned.
  2610      * <p>
  2612      * <p>
  2611      * Otherwise, if there is no character with a code greater than
  2613      * Otherwise, if all characters in this string are space (as
  2612      * {@code '\u005Cu0020'} in the string, then a
  2614      * defined above), then a  {@code String} object representing an
  2613      * {@code String} object representing an empty string is
  2615      * empty string is returned.
  2614      * returned.
       
  2615      * <p>
  2616      * <p>
  2616      * Otherwise, let <i>k</i> be the index of the first character in the
  2617      * Otherwise, let <i>k</i> be the index of the first character in the
  2617      * string whose code is greater than {@code '\u005Cu0020'}, and let
  2618      * string whose code is not a space (as defined above) and let
  2618      * <i>m</i> be the index of the last character in the string whose code
  2619      * <i>m</i> be the index of the last character in the string whose code
  2619      * is greater than {@code '\u005Cu0020'}. A {@code String}
  2620      * is not a space (as defined above). A {@code String}
  2620      * object is returned, representing the substring of this string that
  2621      * object is returned, representing the substring of this string that
  2621      * begins with the character at index <i>k</i> and ends with the
  2622      * begins with the character at index <i>k</i> and ends with the
  2622      * character at index <i>m</i>-that is, the result of
  2623      * character at index <i>m</i>-that is, the result of
  2623      * {@code this.substring(k, m + 1)}.
  2624      * {@code this.substring(k, m + 1)}.
  2624      * <p>
  2625      * <p>
  2625      * This method may be used to trim whitespace (as defined above) from
  2626      * This method may be used to trim space (as defined above) from
  2626      * the beginning and end of a string.
  2627      * the beginning and end of a string.
  2627      *
  2628      *
  2628      * @return  A string whose value is this string, with any leading and trailing white
  2629      * @return  a string whose value is this string, with all leading
  2629      *          space removed, or this string if it has no leading or
  2630      *          and trailing space removed, or this string if it
  2630      *          trailing white space.
  2631      *          has no leading or trailing space.
  2631      */
  2632      */
  2632     public String trim() {
  2633     public String trim() {
  2633         String ret = isLatin1() ? StringLatin1.trim(value)
  2634         String ret = isLatin1() ? StringLatin1.trim(value)
  2634                                 : StringUTF16.trim(value);
  2635                                 : StringUTF16.trim(value);
  2635         return ret == null ? this : ret;
  2636         return ret == null ? this : ret;