-
What is the output of this program?
import java.util.*;
public class Collection_iterators_Example
{
public static void main(String args[])
{
LinkedList listobject = new LinkedList();
listobject.add(new Integer(10));
listobject.add(new Integer(9));
listobject.add(new Integer(6));
listobject.add(new Integer(11));
Iterator Itr = listobject.iterator();
Collections.reverse(listobject);
Collections.sort(listobject);
while(Itr.hasNext())
System.out.print(Itr.next() + " ");
}
}
-
- 10 9 6 11
- 10 9 6
- 6 9 10 11
- 11 10 9 6
- None of these
Correct Option: C
Collections.sort(listobject) sorts the given list, the listobject was 10->9->6->11 after sorting it became 6->9->10->11.