Monday, March 28, 2011

Sort ArrayList In Java

We have multiple options to sort ArrayList in Java. We can use iterator , iterate each and every element of ArrayList & use any sorting algorithm to sort.
But Collection framework of Java also provide sort method.

Sort Array List in Java with Examples:

List data = new ArrayList();
data.add(4);
data.add(2);
data.add(1);
data.add(3);


Collections.sort(data);

No comments:

Post a Comment