You can use this:

new StringBuilder(hi).reverse().toString()

StringBuilder was added in Java 5. For versions prior to Java 5, the StringBuffer class can be used instead — it has the same API.

Answer from Daniel Brockman on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › reverse-a-string-in-java
Reverse a String in Java - GeeksforGeeks
In Java, reversing a string means rearranging its characters from last to first. It’s a common programming task used in algorithms, data processing, and interviews.
Published   October 14, 2025
🌐
Simplilearn
simplilearn.com › home › resources › software development › how to reverse a string in java: 12 best methods
How to Reverse a String in Java: 12 Best Methods
May 5, 2025 - How to Reverse a String in Java? 1. Using toCharArray() 2. Using StringBuilder 3. Using While Loop/For Loop 4. Converting a String to Bytes 5. Using ArrayList
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Codecademy
codecademy.com › docs › java › stringbuilder › .reverse()
Java | StringBuilder | .reverse() | Codecademy
August 22, 2022 - The .reverse() method returns a modified StringBuilder object with its character sequence rearranged in the opposite order. This is the most straightforward way to reverse a string in Java.
🌐
W3Schools
w3schools.com › java › java_howto_reverse_string.asp
Java How To Reverse a String
Java Wrapper Classes Java Generics Java Annotations Java RegEx Java Threads Java Lambda Java Advanced Sorting ... How Tos Add Two Numbers Swap Two Variables Even or Odd Number Reverse a Number Positive or Negative Square Root Area of Rectangle Celsius to Fahrenheit Sum of Digits Check Armstrong Num Random Number Count Words Count Vowels in a String Remove Vowels Count Digits in a String Reverse a String Palindrome Check Check Anagram Convert String to Array Remove Whitespace Count Character Frequency Sum of Array Elements Find Array Average Sort an Array Find Smallest Element Find Largest Element Second Largest Array Min and Max Array Merge Two Arrays Remove Duplicates Find Duplicates Shuffle an Array Factorial of a Number Fibonacci Sequence Find GCD Check Prime Number ArrayList Loop HashMap Loop Loop Through an Enum
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › reverse-a-string-in-java
Reverse a String in Java? - A Complete Guide
October 25, 2025 - Each character must be added to the 'reversed' string in reverse order using the '+=' operator. Finally, return the 'reversed' string. In the main Java Method, call the 'reverse' method with an example string and print out the original and reversed string
🌐
Programiz
programiz.com › java-programming › examples › reverse-number
Java Program to Reverse a Number
Become a certified Java programmer. Try Programiz PRO! ... class Main { public static void main(String[] args) { int num = 1234, reversed = 0; System.out.println("Original Number: " + num); // run loop until num becomes 0 while(num != 0) { // get last digit from num int digit = num % 10; reversed = reversed * 10 + digit; // remove the last digit from num num /= 10; } System.out.println("Reversed Number: " + reversed); } }
🌐
Baeldung
baeldung.com › home › java › java string › how to reverse a string in java
How to Reverse a String in Java | Baeldung
January 8, 2024 - We know that strings are immutable in Java. An immutable object is an object whose internal state remains constant after it has been entirely created. Therefore, we cannot reverse a String by modifying it.
Find elsewhere
🌐
Vultr Docs
docs.vultr.com › java › examples › reverse-a-number
Java Program to Reverse a Number | Vultr Docs
April 10, 2025 - In this code, as long as the number is not zero, the last digit is peeled off using the modulus operation, added to the reverse, and the original number is reduced by dividing by 10. This loop effectively places the last digit of the number at the front, achieving the reverse of a number in Java.
🌐
Medium
medium.com › @AlexanderObregon › javas-stringbuilder-reverse-method-explained-b2b701ee2029
Java’s StringBuilder.reverse() Method Explained | Medium
October 3, 2024 - In Java, working with strings efficiently is an important skill for any developer. One method that comes in handy when manipulating strings is reverse(), part of the StringBuilder class in the java.lang package. This method allows you to reverse the order of characters in a string, a useful operation for various tasks such as checking palindromes or reversing data streams.
🌐
DEV Community
dev.to › vimala_jeyakumar_de64a9b2 › reverse-in-java-49fp
Reverse in java - DEV Community
February 11, 2025 - ->In Java, "reverse" refers to the process of changing the order of elements in a data structure so that they appear in the opposite sequence.
🌐
GeeksforGeeks
geeksforgeeks.org › java › collections-reverse-method-in-java-with-examples
Collections.reverse() Method in Java with Examples - GeeksforGeeks
Note: It does not sort the elements, it simply reverses their current order. This class is present in java.util package so the syntax is as follows:
Published   July 23, 2025
🌐
Emeritus
emeritus.org › home › blog › information technology › 9 most convenient ways to reverse a string in java
9 Most Convenient Ways to Reverse a String in Java
September 24, 2024 - In the above example, a for-each iterative loop converts the input string into a list of characters. Next, the ‘Collections.reverse()’ method reverses the character list. Lastly, the reversed character list converts back to a string using a StringBuilder class and another iterative for-each loop. ALSO READ: Here Are 5 Important Reasons to Learn Java Programming in 2024
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-reverse-number-program
Reverse Number Program in Java - GeeksforGeeks
In Java, reversing a number means that the digit at the first position should be swapped with the last digit, the second digit will be swapped with the second last digit, and so on, till the middle element.
Published   July 23, 2025
🌐
Javatpoint
javatpoint.com › how-to-reverse-string-in-java
How to Reverse String in Java - javatpoint
There are many ways to reverse String in Java. We can reverse String using StringBuffer, StringBuilder, iteration etc. Let's see the ways to reverse String in Java.
🌐
GeeksforGeeks
geeksforgeeks.org › java › reverse-an-array-in-java
Reverse an Array in Java - GeeksforGeeks
July 11, 2025 - When we are working with a String array, we can use a StringBuilder and append each array element with a for loop decrementing from the array's length, then convert the StringBuilder to a string, and split back into an array. ... // Java Program for Reversing an array // using StringBuilder import java.util.Arrays; class Geeks { public static void main (String[] args) { String[] arr = {"Hello", "World"}; StringBuilder r = new StringBuilder(); for (int i = arr.length; i > 0; i--) { r.append(arr[i - 1]).append(" "); }; String[] ra = r.toString().split(" "); System.out.println(Arrays.toString(ra)); } }
🌐
GeeksforGeeks
geeksforgeeks.org › java › stringbuilder-reverse-in-java-with-examples
StringBuilder reverse() in Java with Examples - GeeksforGeeks
January 22, 2026 - The reverse method of the StringBuilder class is used to reverse the sequence of characters in a StringBuilder object.
🌐
Sololearn
sololearn.com › en › Discuss › 2805778 › how-to-reverse-a-string-in-java
How to reverse a string in java | Sololearn: Learn to code for FREE!
June 7, 2021 - Narashima Murthy, In case you didn't know what tags in the forum is for https://code.sololearn.com/W3uiji9X28C1/?ref=app ... If you prefer not to use an array and keep it simple with just Strings, then: String myWord = "abc"; String reversed = ""; for (int i = myWord.length() - 1; i >= 0; i--) reversed += myWord.charAt(i); System.out.println(reversed);
🌐
CodeGym
codegym.cc › java blog › strings in java › reverse a string in java
Reverse a String in Java
October 11, 2023 - “Start reading a String beginning from its last character all the way up to the first character. Bingo! that was your reversed string." Here’s a demonstration of how it will look like. Input String = "X Y Z"; Output String = "Z Y X" Input String = "1 2 3"; Output String = "3 2 1"; Input String = "I love Java!"; Output String = "!avaJ evol I";