• 2022-06-14
    以下程序的运行结果是()import java.util.*;public class TreeMapExample { public static void main(String[] args){ SortedMap map = new TreeMap();//创建TreeMap实例对象 map.put(3,"John"); map.put(2, "Tome"); map.put(1,"Todd"); map.put(5,"Jane"); map.put(4, "William");//新添加一个元素,sortedMap将会自动排序 for(Object k : map.keySet()){//以for-each语句对sortedMap集合进行遍历 System.out.println(k + ":" + map.get(k)); } }}
    A: 编译错误
    B: 运行时异常
    C: 1:Todd
  • 举一反三