单项选择题
下列的选项中关于Set集合的特点的说法正确的是()?
A.其元素无序,且不可重复
B.有顺序,元素可以重复
C.底层用数组实现的
D.其元素是键值对方式
点击查看答案
相关考题
-
单项选择题
java中,关于函数hashcode()与函数equals()的理解有误的是()
A.hashcode()不等,equals()一定也不等
B.hashcode()相等,equals()可能相等,也可能不等
C.equals()方法判断相等的两个对象,hashcode()一定相等
D.equals()方法判断不相等的两个对象,hashcode()一定不相等 -
单项选择题
有下面代码importjava.util.*;classStudent{intage;Stringname;publicStudent(){}publicStudent(Stringname,intage){this.name=name;this.age=age;}publicinthashCode(){returnname.hashCode()+age;}publicbooleanequals(Objecto){if(o==null)returnfalse;if(o==this)returntrue;if(o.getClass()!=this.getClass())returnfalse;Studentstu=(Student)o;if(stu.name.equals(name)&&stu.age==age)returntrue;elsereturnfalse;}}publicclassTestHashSet{publicstaticvoidmain(Stringargs[]){Setset=newHashSet();Studentstu1=newStudent();Studentstu2=newStudent(“Tom”,18);Studentstu3=newStudent(“Tom”,18);set.add(stu1);set.add(stu2);set.add(stu3);System.out.println(set.size());}}下列说法正确的是()
A.编译错误
B.编译正确,运行时异常
C.编译运行都正确,输出结果为3
D.编译运行都正确,输出结果为2 -
单项选择题
请甄别下列对二叉树的使用和理解正确的是()
A.二叉树(BinaryTree)是n(n≥0)个结点的有限集
B.0个结点的树不可以称为二叉树
C.1个结点的树不可以称为二叉树
D.二叉树必须有左右结点
