The methods are executed from left to right. The result of a method becomes the object on which the next method is invoked. Therefore all methods chained in this way must return some type instead of "void".
start at the beginning...you have 'someThing'. You call 'toString()' on it, which returns a string.
on THAT string, you call the 'replaceALL()' method, which returns a string.
on THAT string, you call 'trim()', which returns a string.
on THAT string, you call 'replaceAll()', which returns a string...
which is never saved. None of the string methods ever change the current string, they only build NEW strings and return those. So, you have done all this work, created (at least) four new strings, then never save what you get. You've basically done all this work for nothing. You would need to write something like
newString would then have the changes, and you could then use it somewhere.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors