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 is faster call by value or call by reference?
Can we have a try block without catch block?
What is the meaning of nullable?
What 5 doubled?
Can we call the run() method instead of start()?
What does singleton mean in java?
What restrictions are placed on method overloading?
Why is java not 100% pure oops?
Explain the purpose of garbage collection in Java?
How many bytes are there?
What is a module function?
What is argument in java?