I have an array of objects.
Is it possible to make a new array that is a copy of this array, but in reverse order? I was looking for something like this.
// my array ArrayList<Element> mElements = new ArrayList<Element>(); // new array ArrayList<Element> tempElements = mElements; tempElements.reverse(); // something to reverse the order of the array
This example demonstrate about How to reverse of integer array in android listview. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. In the above result, we had shown reversed array.
You can do this in two steps:
ArrayList<Element> tempElements = new ArrayList<Element>(mElements); Collections.reverse(tempElements);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With