How to reverse the elements in a Single dimension array and display the output

By: Ganesh Iyer Viewed: 192 times  Printer Friendly Format    


This sample Java code shows How to reverse the elements in a Single dimension array and display the output.
class reversArray
{
   public static void main(String[] args)
   {
    int i;
   String[] s = new String[4];

     s[0]=\"My\";
     s[1]=\"Leg\";
     s[2]=\"is\";
     s[3]=\"cut\";

    for(i=s.length-1; i>=0; i--)
    {
       System.out.println(\"String reverse \"+s[i]);
    }
  }
}


Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial