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 |
How to create an interface?
when i write string s1="java"; in one program(application) and string s2="java"; in another application on the same jvm will both objects s2,s2 will refer to same memory location where "java" is stored in string pool.
What are 4 pillers of object orinted programming?
Can we declare a class as abstract without having any abstract method?
Is 64bit faster than 32 bit?
can u override the start() method of Thread class
Name the class that used to read objects directly from a stream?
Write a program to check for a prime number in java?
how to print hello world every second till i have pressed enter key ???
What is a boolean flag in java?
What is collection class in java?
What are parsing rules?