阅读下列的程序import java.util.*;class Student { String name; String age; public Student(String name, String age) {this.name = name;this.age = age; } public String toString() {return name + ":" + age; }}public class Example{ public static void main(String[] args) {Set set = new HashSet();set.add(new Student("Tom", "10"));set.add(new Student("Jerry", "10"));set.add(new Student("Tom", "10")); }}下列选项中,程序的运行结果是( )
查看答案
阅读下段代码import java.util.*;public class Example { public static void main(String[] args) {TreeSet ts = new TreeSet(); // 创建TreeSet集合ts.add("Jack"); // 向TreeSet集合中添加元素ts.add("Helena");ts.add("Helena");ts.add("Eve");Iterator it = ts.iterator(); // 获取Iterator对象while(it.hasNext()) { System.out.print(it.next()+" ");} }}下列选项中,程序的运行结果是( )
A. JackHelenaHelenaEve
B. EveHelenaHelenaJack
C. JackHelenaEve
D. EveHelenaJack
下列选项中,不属于TreeMap类的方法的是( )
A. firstKey()
B. isEmpty()
C. lowerEntry(K key)
D. higherKey(K key)
阅读下段代码import java.util.Enumeration;import java.util.Properties;public class Demo { public static void main(String[] args) {Properties p = new Properties();p.setProperty("userame", "tom");Enumeration names = p.propertyNames();while (names.hasMoreElements()) {String key = (String) names.nextElement();String value = p.getProperty(key);System.out.println(key + " = " + value);} }}下列选项中,哪一个是程序执行后的结果( )
A. key = tom
B. username = tom
C. username tom
D. 编译失败
Hashtable类有一个子类【】,主要用来存储字符串类型的键和值。