top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to reverse an array in Java?

+3 votes
352 views
How to reverse an array in Java?
posted Mar 28, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Something like -

for(int i = 0; i < mydata.length/2; i++)
{
    int temp = mydata[i];
    mydata[i] = mydata[mydata.length - i - 1];
    mydata[mydata.length - i - 1] = temp;
}
answer Mar 30, 2015 by Salil Agrawal
...