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 is compile time polymorphism?
20 Answers CTS, Elementus Technologies, Oracle,
What are white spaces in java?
what value will be return by the read() method once it reaches the end-of-file? a. Throws EOException b. Return null c. Return -1 d. Read method return nothing, because it is void method
Name two subclasses of the TextComponent class?
what is real-time example of runtime polymorphism and compile time polymorphism
Which is better stringbuffer or stringbuilder?
What is OOPS Concept?
Explain pass by reference and pass by value?
Can we overload the constructors?
What is variable and rules of variable?
What is the buffer limit?
What is the purpose of an interface?