Serguey Asael Shinder: String.strip() and trim() are not the same: Unicode white space vs U+0020
Java has two methods that look interchangeable for cleaning up the ends of a string: String.trim() and String.strip(). The Java 25 java.lang.String documentation defines them differently, and the difference is not cosmetic. (There is no JDK on the machine used to write this, so every statement here is taken from the javadoc, not from running code.)
What the javadoc says. trim() "Returns a string whose value is this string, with all leading and trailing space removed, where space is defined as any character whose codepoint is less than or equal to 'U+0020' (the space character)." strip() "Returns a string whose value is this string, with all leading and trailing white space removed," and its "See Also" points to Character.isWhitespace(int). strip() is marked Since: 11; trim() has been there from the start.
Why the definitions diverge. trim() uses a numeric cut-off: every code point from U+0000 up to and including U+0020 is treated as "space". That sweeps in control characters — tab (U+0009), newline (U+000A), carriage return (U+000D) all have code points below U+0020, so trim() removes them. But it is blind in two directions at once. It removes some characters that are not whitespace at all (other C0 control characters below U+0020), and it misses whitespace above U+0020 — for example a non-breaking space (U+00A0) or other Unicode space characters, which trim() leaves in place because their code points exceed U+0020.

Where it bites. strip() instead delegates the decision to Character.isWhitespace, the Unicode-aware definition. So on text that carries a non-breaking space at the end — common in copied web content and some locale-formatted numbers — trim() will leave that character attached while strip() removes it. The practical rule from the javadoc: use strip() (and its one-sided relatives stripLeading() and stripTrailing()) when "whitespace" should mean what Unicode means by it, which is almost always what you want for user- or web-sourced text; trim()'s U+0020 rule is a legacy definition that predates the Unicode-aware methods.
Because this machine has no JDK, the behaviour above is reported from the Java 25 API documentation rather than verified by execution; the javadoc is the authoritative specification for what each method is required to do.
Source: Java 25 API documentation, java.lang.String (strip, trim, stripLeading) — https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html