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 |
What does ide stand for?
Should a main method be compulsorily declared in all java classes?
Can we use string in switch case in java?
What is use of functional interface in java 8? Explain
can write code for serialization ?
What is a default package ?
What is nested top-level class?
Is minecraft 1.15 out?
Explain about the dynamic behavior of core java?
Can a method inside a interface be declared as final?
Can we store variables in local blocks?
What are different types of arrays?