toString() method returns the string or textual representation of an object.
The string specifies the object’s class which is followed by ‘@’ sign and the hashcode of the object (unsigned hexadecimal representation).
You may use a number of ways for reversing the strings in Java programs. If you are working with mutable strings by using StringBuilder or StringBuffer class then these classes have built-in reverse method.
The Java indexOf returns the index of given character or substring for the first occurrence in the specified string. To get the last occurrence of the given substring or character, use the lastIndexOf() method.