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
what is the volatile modifier for? : Java thread
What advantage do java's layout managers provide over traditional windowing systems?
Does list allow duplicates in java?
how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)
What is the symbol for space?
What is application tier?
What is a website container?
What are untrusted applets?
Why do we use bufferedreader?
What is the new line character?
Can a class be declared as static?
What is the static keyword?
How many bits is size_t?
Why bytecode is called bytecode?
Wha is the output from system.out.println(“hello”+null); ?