Trim ALL whitespaces from a String in Java..

..for no reason.

class A {
    public static void main(String[] args) {
        final String expectedOutput = "abc";
        final String[] stringsToTest = {"abc", " abc", "abc ", "a b c", "   abc", "abc    ", "a   bc"};
        for (String string : stringsToTest) {
            System.out.println(trimAllWhiteSpace(string).equals(expectedOutput));
        }
    }
 
    static String trimAllWhiteSpace(final String stringToTrim) {
        final char[] stringToTrimAsCharArray = stringToTrim.toCharArray();
        final char[] trimmedStringAsCharArray = new char[stringToTrim.length()];
 
        int trimmedStringPos = 0;
        for (final char c : stringToTrimAsCharArray) {
            if (c != ' ') {
                trimmedStringAsCharArray[trimmedStringPos] = c;
                trimmedStringPos++;
            }
        }
        final String stringTrimmed = new String(trimmedStringAsCharArray).substring(0, trimmedStringPos);
        return stringTrimmed;
    }
}

And the output will be:
true
true
true
true
true
true
true