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
  • 39,600
  • 8
  • 50
  • 84
user3242607
  • 209
  • 1
  • 11
  • 28

3 Answers3

1

No need for libraries, plain Java will do

new StringBuilder("Bird").reverse().toString();
Jan Groth
  • 13,207
  • 5
  • 37
  • 52
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,211
  • 21
  • 86
  • 146