Suppose there is an array list [10,5,20,19,15,24].Print them
in ascending & descending order in collection framework
concept ???
Answer Posted / 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 |
Post New Answer View All Answers
How do I stop concurrentmodificationexception?
What is static class
Why stringbuffer is faster than string?
What is qualitative variable?
Can sleep() method causes another thread to sleep?
Does java list allow null?
How many types of memory areas are allocated by jvm?
What is a local, member and a class variable?
What is collections framework?
Describe method overriding
What are the basic concepts of OOPS in java?
What is the use of http-tunneling in rmi?
What are the new features in java 8? Explain
What is immutable data?
What is the difference between a choice and a list?