String reverse function in java => http://forttercstaphes.nnmcloud.ru/d?s=YToyOntzOjc6InJlZmVyZXIiO3M6MjE6Imh0dHA6Ly9iaXRiaW4uaXQyX2RsLyI7czozOiJrZXkiO3M6MzE6IlN0cmluZyByZXZlcnNlIGZ1bmN0aW9uIGluIGphdmEiO30= Here is the code snippet to reverse the string using reverse method of StringBuffer class. So here i am providing solutions for both. First of all, the difference is StringBuffer is threadsafe and StringBuilder is not. I think this one is efficient. Solution Following example shows how to reverse a String after taking it from command line argument. The important thing is to memorize the state of the loop and the answer, reversed string built from the characters considered so far and the current character. If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to contribute geeksforgeeks. Use below given solution instead. Fortunately, it is quiet easy to make a method to do it. Convert the input string into character array by using the toCharArray built in method of the String Class. String class in java do not have reverse method , StringBuilder class does have built in reverse method. Reverse a String in Java - The last method is converting string into bytes. The user will input the string to be reversed. If you use for loop for the traversal of the string then it would be like this. Other than that it is without loop or any inbuilt funtions. If you have any Queries related this then you can reach me on First of all i am confused, are you want to reverse on the basis of letters or words. So here i am providing solutions for both. Another string reverse function in java based on letters- import java. Based on words- import java. If that is the case, then for loops can be simulated by recursion. Actually iterative constructs are just syntactic sugar for tail recursion. The important thing is to memorize the state of the loop and the answer, reversed string built from the characters considered so far and the current character. Once curIndex hits the s. I use this algorithm to reverse string.