A
Q. What will be the output of the following code
Code:
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
public class SortSet {
public static void main(String…a)
{
Collection<Integer> collection = new HashSet<Integer>();
collection.add(3);
collection.add(1);
collection.add(2); {
Set<Integer> treeSet=new TreeSet<Integer>(collection);
System.out.println(treeSet);
}
}
}
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
public class SortSet {
public static void main(String…a)
{
Collection<Integer> collection = new HashSet<Integer>();
collection.add(3);
collection.add(1);
collection.add(2); {
Set<Integer> treeSet=new TreeSet<Integer>(collection);
System.out.println(treeSet);
}
}
}
- Correct Answer - Option(A)
- Views: 11
- Filed under category Java
- Hashtags:
Discusssion
Login to discuss.