Rabu, 12 Agustus 2020

How to reverse an ArrayList in place in Java - Coding Interview Questions

You can reverse an ArrayList in place in Java by using the same algorithm we have used to reverse an array in place in Java. If you have already solved that problem then It's a no-brainer because ArrayList is nothing but a dynamic array, which can resize itself. All elements of an array are stored in the internal array itself. By the way, if you need to reverse an ArrayList then you should be using the Collections.reverse() method provided by the Java Collection framework. It's a generic method, so you can not only reverse an ArrayList but also Vector, LinkedList, CopyOnWriteArrayList, or any other List implementation.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon