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 are the disadvantages of object oriented programming?
Does java support multiple inheritances?
Can we declare register variable as global?
How is a structure different from array ?
Discuss different types of errors that generally occur while programming.
What is bytecode verifier?
Explain the importance of finally over return statement?
What is the difference between access specifiers and access modifiers in java? 16
What are new features introduced with java 8 ?
What is a lock or purpose of locks in java?
what do you mean by classloader in java?
Does every java program need a main?
What does flagged out mean?
What is the difference between preemptive scheduling and time slicing?
What are the advantages of java inner classes?