Programming Tutorials

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

By: Ganesh Iyer in Java Tutorials on 2009-05-29  

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]);
    }
  }
}





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Java )

Latest Articles (in Java)