java program to reverse a string without using api