Sort ArrayList in java

In the previous post, we have seen how to remove an element at a specified index. In this post, we will see how to sort arraylist in java.

We use the collections class to sort the arraylist.



Example for sorting String:

We will see how to sort the string.


List of fruits before sorting : [Orange, Mango, Apple, Grapes] List of fruits after sorting : [Apple, Grapes, Mango, Orange]


Example for sorting the integer:

We will see how to sort the Integer values.


List of integer before sorting : [4, 2, 6, 1] List of integer after sorting : [1, 2, 4, 6]

Have any question or suggestion for us?Please feel free to post in Q&A Forum



Remove an element at a particular index from the array list
Sort the ArrayList in descending order
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

Leave a Reply

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