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 |
Should a main method be compulsorily declared in all java classes?
how and when compiler knows that the Java code throws the checked Exception.
How do you sing an Applet ?
What is the difference between declaration and definition in java?
When the constructor of a class is invoked?
Why bytecode is called bytecode?
Can we force the garbage collection to run?
can we write a program with out a class in core java?
If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?
How to perform linear search in java?
What does string [] args mean?
23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an <applet> tag?. code,height & width. 26. What does 'CODEBASE' in an applet tag specify?. Files absolute path.