Reputation: 65
package collection;
import java.util.*;
public class SortedSet {
public static void main(String[] args) {
// TODO Auto-generated method stub
SortedSet set = new TreeSet();
}
}
It giving me following error:
Type mismatch: cannot convert from TreeSet to SortedSet
Upvotes: 3
Views: 1064
Reputation: 188
You have two options: - change the name of class, - change type of set to TreeSet like TreeSer set = new TreeSet();
Upvotes: 1
Reputation: 393811
Your class name is also SortedSet
, so it is hiding java.util.SortedSet
. Either rename your class (the preferred option) or use the full name of the interface in your variable declaration.
Upvotes: 3