in reply to Re: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell) (a Java 1.5 version)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
Of course the above is broken :) It appends a trailing empty space. There are two ways to fix it:
1) return result.toString().trim(); instead of return result.substring(1);
2) filter out zero-length pieces in the for loop with something like if( pc.length() == 0 )