
program to sort a list of numbers in decendimg order

Hi Friend,
Try the following code:
import java.util.*;
class SortListInDescendingOrder{
public static void main(String[] args)
{
ArrayList<Integer> list=new ArrayList<Integer>();
list.add(5);
list.add(2);
list.add(6);
list.add(1);
list.add(3);
list.add(4);
Collections.sort(list,Collections.reverseOrder());
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.