Explanation : In line number 06 i have used the String.toCharArray() method to store the converted(to array of characters) value of the string in Array of characters "str" .

charAt(index) is the build in method in Java String it simply returns the character at the index "index"(index is an integer) it can not be used to assign the value For example i cant do this s.charAt(0) = 'c' . At line #10 the value of first character of the "str" is copied in the variable temp. In 1st iteration of the loop the first char in "str" is replaced by the last and last is replaced by the first one.

Similarly in second iteration of the loop 2nd character is replaced by second last and vice versa. This process will carry on until the whole Array is reversed. And at the end the result is printed in line #18.

Explanation : Here i used StringBuffer. I saved the string in the StringBuffer. Then i used the reverse(reverse method is build in for StringBuffer) method for StringBuffer to reverse the it. At the end i copied the saved the converted(to string) value of StringBuffer in the string value and displayed it.

Share other methods which you find useful too!!

I Hope You Learned Something from this Post if you have any problem comment below i will reply as soon as possible, FOLLOW Me for more Good Stuff :)