Android - reverse array order

I have an array of objects.

Is it possible to create a new array that is a copy of this array, but in the 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 
+46
android arrays reverse
Mar 23 2018-11-23T00:
source share
1 answer

You can do this in two steps:

 ArrayList<Element> tempElements = new ArrayList<Element>(mElements); Collections.reverse(tempElements); 
+193
Mar 23 2018-11-23T00:
source share



All Articles