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 the root class for all Java classes?
What is an event?
What is the difference between JVM and JRE?
How do you differentiate abstract class from interface?
5 Coding best practices you learned in java?
What are desktop procedures?
Describe inheritance as applied to java?
Variable of the boolean type is automatically initialized as?
make a method which any number and any type of argument and print sum of that arguments.....
there are N number of matchboxes numbered 1...N.each matchbox contain various number of stick.Two player can alternatevely pick some amount of stick from the higest stick containing box . The player is condidered win if there is no stick after his move.Find the final move so that the move player win. Note:In case the number of stick is equal ,pick the stick from the higest numbered box.
What is the use of beaninfo?
Mention some features of java?