protected static String reverse(String str){
  StringBuilder buf=new StringBuilder();
  for (int i=str.length() - 1; i >= 0; --i) {
    buf.append(str.charAt(i));
  }
  return buf.toString();
}

protected static String reverse ( String str ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = str . length ( ) - 1 ; i >= 0 ; -- i ) { buf . append ( str . charAt ( i ) ) ; } return buf . toString ( ) ; }
returns the reverse of the given string .
