reverse a string in java using collections