About 2,020,000 results
Open links in new tab
  1. Reverse a String in Java - GeeksforGeeks

    Mar 27, 2025 · We can use character array to reverse a string. Follow Steps mentioned below: First, convert String to character array by using the built-in Java String class method toCharArray(). Then, scan the string from end to start, and print the character one by one.

  2. java - How do I reverse a String array? - Stack Overflow

    Nov 7, 2014 · First, you could use Arrays.toString(Object[]) to print your String[]. Then you can iterate half of the array and swap the String at the current position with it's corresponding pair (at the length - current index, remembering that Java arrays are zero indexed so the last position in an array is array.length - 1). Finally, print again. Like,

  3. Reverse String Using Array in Java - Tpoint Tech

    Mar 21, 2025 · To reverse a string, the easiest technique is to convert it to a character array and then swap the characters at both ends of the array. In Java, you can do the following: The original String is Hello World! Reversed String is !dlroW olleH. The toCharArray () method converts the input string into a character array.

  4. Reverse a String in Java in 10 different ways | Techie Delight

    Apr 1, 2024 · This post covers 10 different ways to reverse a string in java by using StringBuilder, StringBuffer, Stack data structure, Java Collections framework reverse() method, character array, byte array, + (string concatenation) operator, Unicode right-to-left override (RLO) character, recursion, and substring() function.

  5. Java Collections.reverse - Complete Tutorial with Examples

    Apr 20, 2025 · Java Collections.reverse Method. Last modified: April 20, 2025 The Collections.reverse method is a utility function in Java's Collections framework. It reverses the order of elements in a specified list. This operation is …

  6. How to Reverse a String in Java:13 Best Methods - Simplilearn

    Apr 14, 2025 · You can use Collections.reverse() to reverse a Java string. Use these steps: Create an empty ArrayList of characters, then initialize it with the characters of the given string with String.toCharArray().

  7. Java How To Reverse a String - W3Schools

    You can easily reverse a string by characters with the following example: reversedStr = originalStr.charAt(i) + reversedStr; } System.out.println("Reversed string: "+ reversedStr);

  8. Reverse an Array in Java - GeeksforGeeks

    6 days ago · In Java, there are multiple ways to reverse an array. We can reverse it manually or by using built-in Java methods. In this article, we will discuss different methods to reverse an array with examples. Let us first see the most common way to reverse an array in Java, then we will discuss other ways. Example: Reverse Using a Loop.

  9. String array reverse Java - Stack Overflow

    Mar 9, 2014 · I am trying to reverse all the strings in an array in java, but seem to over write all of them with the first. int flag=0; String reverse; for(int i=0;i<n;i++) // n is declared globally as number of strings. reverse=""; for (int j=s[i].length()-1;i>=0;i--) reverse=reverse+s[i].charAt(j); if(s[i].equals(reverse)) System.out.println(s[i]); .

  10. java - How do I reverse every string in a string array ... - Stack Overflow

    May 19, 2020 · Simply iterate the array, and replace each entry with its reverse. You can use a StringBuilder to reverse a String, calling StringBuilder.reverse. Like, public static void reverse(String[] array) { for (int i = 0; i < array.length; i++) { array[i] = new StringBuilder(array[i]).reverse().toString(); } } And then to test it

  11. Some results have been removed
Refresh