Define a method for reversing a string:
int i, c=0, res;
static void StringReverse(String s)
{
char ch[]=new char[s.length()];
for(i=0;i < s.length();i++)
ch[i]=s.charAt(i);
// Now print in reverse from length-1 to 0
for(i=s.length()-1;i>=0;i--)
System.out.print(ch[i]);
}