开发者社区> 问答> 正文

java代码编译求助

public class FindDups {
    public static void main(String[] args) {
        Set<String> s = new HashSet<String>();
        for (String a : args)
            if (!s.add(a))
                System.out.println("Duplicate detected: " + a);
 
        System.out.println(s.size() + " distinct words: " + s);
    }
<p>
    <span style="font-size:9pt;line-height:1.5;">}</span>
</p>
 
<p>
    为什么Set<String> s = new HashSet<String>()无法通过编译,“cannot convert from HashSet<String> to Set<String><span>”,HashSet不是Set的实现吗??怎么这样写不行的??求助各位大神</span>
</p>

展开
收起
爵霸 2016-06-13 10:02:39 1979 0
1 条回答
写回答
取消 提交回答
  • Java开发

    看看import 的是什么类型的set

    2019-07-17 19:35:08
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载