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 |
Can constructor be protected in java?
What are the three parts of a lambda expression? What is the type of lambda expression?
Why heap memory is called heap?
Is it possible to write static method in abstract class? justyfy your answer?
I/O blocking means?
what is the difference between cd & dvd ?
30 Answers Lovely Professional University, Satyam, Sibylsys,
What’s the difference between the methods sleep() and wait()?
How to sort an unsorted array in java?
Difference between class#getinstance() and new operator ?
Which Java operator is right associative?
What is the memory leak in java?
What is a dynamic array java?