Suppose there is an array list [10,5,20,19,15,24].Print them
in ascending & descending order in collection framework
concept ???
Answers were Sorted based on User's Feedback
Answer / abzy wabzy
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MainClass {
public static void main(String[] a) {
List list = new ArrayList();
list.add("A");
list.add("C");
list.add("B");
Collections.sort(list);//for Ascending order
System.out.println(list);
Collections.sort(list, Collections.reverseOrder
());//for descending order
System.out.println(list);
}
}
| Is This Answer Correct ? | 5 Yes | 0 No |
Which list is sorted in java?
What Is Resource Leak?
Can I declare class as static or private?
what is Inheritense
Why constructor has no return type?
What means public static?
what is meant by encapsulation?
what is comparable and comparator interface?
what are the analysis of an object
what is the difference between HashMap and Hashtable
17 Answers Value Labs, Virtusa,
What does replaceall do in java?
What is a module function?