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
Should you use singleton pattern?
What is a method type?
Is oracle java 11 free?
how to open and edit XML file in Weblogic???
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?
What is getkey () in java?
Explain what access modifiers can be used for methods?
Tell me are there implementations for sorting and searching in the java libarary?
What do you mean by constant time complexity?
What are 3 data types?
Explain about member inner classes?
Explain a few methods of overloading best practices in java?
What is the SimpleTimeZone class?
What is a double?
What is passed by reference and pass by value ?