package holding;import static Test_purview.print.*;
import java.util.*;public class Test_Exercise2 {
public static void main(String[] args){
// 为什么Set不能创建
Collection<Integer> c = new HashSet<Integer>();
// Collection<Integer> c = new Set<Integer>(); ----Illegal
for(int i = 0;i<10;i++){
c.add(i);
print(i);
}
for(int i = 0;i<10;i++){
c.addAll(c);
print(c);
}
for(Integer i : c)
print(i);
}
}如题:能创建HashSet不能创建Set?
import java.util.*;public class Test_Exercise2 {
public static void main(String[] args){
// 为什么Set不能创建
Collection<Integer> c = new HashSet<Integer>();
// Collection<Integer> c = new Set<Integer>(); ----Illegal
for(int i = 0;i<10;i++){
c.add(i);
print(i);
}
for(int i = 0;i<10;i++){
c.addAll(c);
print(c);
}
for(Integer i : c)
print(i);
}
}如题:能创建HashSet不能创建Set?
解决方案 »
- jdbc数据库连接池问题
- 今天去面试的英文题,请高手帮忙翻译下啊,处女贴,望支持
- 求一个正则表达式: 空格不能连续
- Error Message: ids for this class must be manually assigned before calling save():
- 用Hibernate做数据更新,如何只更新部分字段?
- 我写了个当前月的日历,可是总天数不对?高手们能指出哪里错了吗?
- 语句执行的过程中,不能弹出新的地址页,谁能帮帮我?哪里出现了问题
- 豁出去了,没有分也要问
- classpath 问题?
- 请问Web服务器与HTTP服务器有什么区别?
- BufferedImage 造成内存溢出
- XML中如何交换两个节点的内容?
Collection<Integer> c = new Set<Integer>() 这么厉害的代码都能写得出来
HashSet是接口的实现类,可以被实例化。