How many spaces will Java String.trim() remove?

java, string, trim

Solution

All of them.

Returns: A copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.

~ Quoted from Java 1.5.0 docs

(But why didn't you just try it and see for yourself?)

Problem

In Java, I have a String like this: ``` " content ". ``` Will `String.trim()` remove all spaces on these sides or just one space on each?

Original source

Related problems