0

I have created an array and i want to print the array elements backwards. I'm completely lost on how to do that. I was thinking I might need to convert this array to a char array. The example below is the method I used to print out the elements in the array. I need a new method that prints each word backwards.

Example:
Bird
DriB

public static void t(String [] list) throws IOException
{
    for (int i = 0; i <list.length; i++)
    {
      System.out.println(list[i]);
    }
}
Anton Savin
  • 40,838
  • 8
  • 54
  • 90
user3242607
  • 219
  • 1
  • 13
  • 28

3 Answers3

1

No need for libraries, plain Java will do

new StringBuilder("Bird").reverse().toString();
Jan Groth
  • 14,039
  • 5
  • 40
  • 55
0

Maybe You can using Apache commons StringUtils

public static void t(String [] list) throws IOException
{
   for (int i = 0; i <list.length; i++)
   {
      String element = list[i];
      String reverseElement = StringUtils.reverse(element);
      System.out.println(reverseElement);
   }
}
Balicanta
  • 109
  • 6
0
public static void t(String [] list) throws IOException
{
    for (int i = list.length; i >= 0; i--)
    {
      System.out.println(list[i]);
    }
}

Count bakwards?

HelpNeeder
  • 6,383
  • 24
  • 91
  • 155