Try these steps:

String[] strDays = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday"};
List<String> list = Arrays.asList(strDays);
Collections.reverse(list);
strDays = (String[]) list.toArray();
Answer from Vijay on Stack Overflow
๐ŸŒ
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.
๐ŸŒ
Software Testing Help
softwaretestinghelp.com โ€บ home โ€บ java โ€บ how to reverse an array in java: 3 methods with examples
How to Reverse An Array In Java: 3 Methods With Examples
March 24, 2020 - The above program defines a string array. By converting it to the list and using the reverse method on it, we reverse the array.
๐ŸŒ
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
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ reverse-a-string-in-java
Reverse a String in Java - GeeksforGeeks
Explanation: Characters are stored in a list and reversed using Collections.reverse(). This approach is helpful when youโ€™re already working with Java collections. StringBuffer is similar to StringBuilder but thread-safe.
Published ย  October 14, 2025
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ java array โ€บ reverse an array in java
Reverse an Array in Java
December 6, 2022 - The same swapping goes on in the for-loop until we hit the middle of the array, at this time the array has been reversed. String[] array = {"A", "B", "C", "D", "E"}; for (int i = 0; i < array.length / 2; i++) { String temp = array[i]; array[i] = array[array.length - 1 - i]; array[array.length - 1 - i] = temp; } System.out.println(Arrays.toString(array)); //[E, D, C, B, A]
Top answer
1 of 5
5

StringBuilder::reverse

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

public static void main(String[] args) {
    String arr[] = { "abc", "def" };
    reverse(arr);
    System.out.println(Arrays.toString(arr));
}

See this code run live at IdeOne.com.

[cba, fed]

2 of 5
1

Stream

The Answer by Elliott Frisch is correct and robust, and should be accepted.

In addition, for fun, here is a version of that code using streams rather than the conventional for loop. I am not claiming this is better.

I do not know of a way for a stream of an array to affect that array. So instead here I make and return a fresh array.

public static String[] reverse( String[] array ) {
    Objects.requireNonNull( array , "Received null argument where an array of `String` was expected. Message # b5c03336-4b9e-4735-a054-16e43aac059e.") ;
    
    Stream< String > stream = Arrays.stream( array ) ;
    String[] result =
            stream
            .map( ( String s ) -> new StringBuilder( s ).reverse().toString() )
            .toArray(String[]::new) 
    ;
    
    return result ;
}

Usage.

    String arr[] = { "abc" , "def" , "mask" } ;
    String arr2[] = Ideone.reverse( arr ) ;
    
    System.out.println( Arrays.toString( arr ) ) ;
    System.out.println( Arrays.toString( arr2 ) ) ;

See that code run live at IdeOne.com.

[abc, def, mask]

[cba, fed, ksam]

๐ŸŒ
Blogger
javahungry.blogspot.com โ€บ 2017 โ€บ 06 โ€บ how-to-reverse-array-in-java-with-example.html
How to Reverse Integer or String Array in Java with Example | Java Hungry
2. Reverse the list using Collections.reverse() method 3. Convert the list back to the array using list.toArray() method. import java.util.*; public class ReverseArray { public static void main (String[] args) throws java.lang.Exception { // Given input array String[] inputArray = ...
Find elsewhere
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2013 โ€บ 03 โ€บ how-to-reverse-array-in-java-int-String-array-example.html
How to Reverse an Array in Java? Integer and String Array Example Tutorial
On a similar note, you can also write your own utility method to reverse Array in Java, and this is even a good programming question. For production usage, I personally prefer tried and tested library methods instead of reinventing the wheel. Apache commons-lang fits the bill, as it offers other convenient API to complement JDK. In this Java tutorial, we will reverse int and String array in Java using ArrayUtils to show How to reverse primitive and object array in Java.
Top answer
1 of 7
3

When I run your code, I didn't get the same error that you posted, but I did notice that null was at the end of each reversed word.

nullyadnoM
nullyadseuT
nullyadsendeW

Which is beacuse when you create a new string array, all it's values default to null:

String[] t = new String[words.length];

The easiest way to fix it is to set it's value to an empty string, before you start adding to it:

public static String[] reverseString(String[] words)
{
    String[] text = new String[words.length];

    for (int i = 0; i < words.length; i++)
    {
        text[i] = "";
        for (int j = words[i].length() - 1; j >= 0; j--)
            text[i] += words[i].charAt(j);
    }
    return text;
}

I have tested this code, and it works perfectly fine for me.

To output the array, instead of using

System.out.println(words);

use the following:

System.out.println(Arrays.toString(words));

This will give you the output:

[yadnoM, yadseuT, yadsendeW]
2 of 7
2

You can transform your string into StringBuilder and it had reverse method. And its always better to use foreach rather than for, until there is actual need.

public String[] reverseString(String[] words) {
    String[] t = new String[words.length];
    for (String wordTemp : words) {
      StringBuilder sb = new StringBuilder(wordTemp);
      t[i] = sb.reverse().toString();   
    }
    return t;
}

Alternate approach :-

public  String[]  reverseString(String[] words)
{
    String[] t=new String[words.length];

    for(int i=0;i<words.length;i++)
    {   
        //added for setting elemennt as emptyString instead of null
        t[i] = "";
        for(int j=words[i].length()-1;j>=0;j--)
        {
            t[i]+=words[i].substring(j,j+1);
        }
    }

    //using loop
    for(int i=0;i<words.length;i++)
    {
         System.out.println(t[i]);
    }
    //using Arrays Method
    System.out.println(Arrays.toString(t));
    return t;
}
๐ŸŒ
PREP INSTA
prepinsta.com โ€บ home โ€บ dsa with java โ€บ reverse an array or string in java
Reverse an array or string in Java | PrepInsta
October 31, 2025 - Learn how to Reverse an Array or String in Java programming language with the help of different methods and built in function....
๐ŸŒ
Javatpoint
javatpoint.com โ€บ java-program-to-print-the-elements-of-an-array-in-reverse-order
Java Program to print the elements of an array in reverse order - Javatpoint
Java Program to print the elements of an array in reverse order - Java Program to print the elements of an array in reverse order on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph, pattern, string etc.
๐ŸŒ
Java67
java67.com โ€บ 2016 โ€บ 10 โ€บ 3-ways-to-reverse-array-in-java-coding-interview-question.html
[Solved] 3 Examples to reverse an Array in Java - Example Tutorial | Java67
You can also use the Apache Commons ArrayUtils.reverse() method to reverse an array in Java. This method is overloaded to reverse byte, short, long, int, float, double, and String array. You can use any of the methods depending upon your array type.
๐ŸŒ
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!
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String text = scanner.nextLine(); char[] arr = text.toCharArray(); for(int i=arr.length-1;i>=0;i--) { System.out.println(arr[i]); } } }
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ reverse-string-java
Reverse a String in Java (with Examples)
September 28, 2024 - Using a for loop, iterate through the array of words in reverse order. Add a space after each word in the StringBuilder. Finally, use the toString() method to convert the StringBuilder to a string.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ reverse an array in java
Reverse an Array in Java - Scaler Topics
April 28, 2024 - An array can be reversed using various methods in Java, such as: Using in-place reversal in which the elements are swapped to place them in reverse order. Using a temporary array to traverse and store the elements in reverse order.
๐ŸŒ
LogicMojo
logicmojo.com โ€บ reverse-a-string-in-java
Reverse a String in Java- Logicmojo
In the code below, copy the String values to an ArrayList object. Then, on the ArrayList object, use the listIterator() function to create a ListIterator object. Use the ListIterator object to iterate over the collection.
๐ŸŒ
The Knowledge Academy
theknowledgeacademy.com โ€บ blog โ€บ reverse-a-string-in-java
Reverse a String in Java? - A Complete Guide
To reverse a String in Java using converting to a byte array, first, use the โ€˜getBytes()โ€™ method to convert the string to a byte array. Create a new byte array with the same length as the original byte array. Copy each element to the new ...
๐ŸŒ
Java Code Geeks
examples.javacodegeeks.com โ€บ home โ€บ java development โ€บ core java
Reverse Array Java Example - Java Code Geeks
February 7, 2022 - You can also use Apache Commons ArrayUtils.reverse() method to reverse any array in Java. This method is overloaded to reverse byte, short, long, int, float, double and String array.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ java_howto_reverse_string.asp
Java How To Reverse a String
Java Wrapper Classes Java Generics ... 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 ...