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 |
is it possible to instantiate the math class?
What is the program development process?
What is proper subset?
How are observer and observable used in java programming?
Difference between JDK, JRE, JVM
16 Answers Deloitte, HCL, Mind Tree, Oracle, Reliance, TCS, ThinkBox,
what is deadlock? : Java thread
Can you override a private or static method in java?
What is flag in java?
What are the types of arrays in java?
Detail discussions on JVM, memory management and garbage collector.
when everything can be done by static block then why do we use main method?.
What is variable explain with example?