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
Which api is provided by java for operations on set of objects?
Does importing a package imports its sub-packages as well in java?
Explain about exception propagation?
Explain the significance of class loaders in bootstrap?
What language is pass by reference?
Does list allow duplicates in java?
Can we force garbage collector to run ?
What is local class in java?
What is difference between path and classpath in java?
Can private class be extended java?
When is the arraystoreexception thrown?
what is encapsulation in java? Explain
Give an example of call be reference significance.
What is generic type?
Differentiate between a class and an object.