Improving performance with a array of million records

I do have a array with million String objects..

ex:String values [] = new String[10000000] 

and I’ve to reverse all the elements and what is the best way of doing it to improve performance?

Answer

You are making you task harder than it needs to be by not using the Collections standard library. Instead of an array use a List then use the standard Collections.reverse() method.

List<String> list = Arrays.asList(values);
Collections.reverse(list);

Leave a Reply

Your email address will not be published. Required fields are marked *