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



Suppose there is an array list [10,5,20,19,15,24].Print them in ascending & descending order in..

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

Suppose there is an array list [10,5,20,19,15,24].Print them in ascending & descending order in..

Answer / sagar

Use
Collections.sort(arraylist)

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

Which is faster call by value or call by reference?

1 Answers  


Can we have a try block without catch block?

1 Answers  


What is the meaning of nullable?

1 Answers  


What 5 doubled?

1 Answers  


Can we call the run() method instead of start()?

1 Answers  


What does singleton mean in java?

1 Answers  


What restrictions are placed on method overloading?

1 Answers  


Why is java not 100% pure oops?

1 Answers  


Explain the purpose of garbage collection in Java?

1 Answers   BirlaSoft,


How many bytes are there?

1 Answers  


What is a module function?

1 Answers  


What is argument in java?

1 Answers  


Categories