A: <;Entry>;map.keySet()Entry
B: <;Entry<;Integer,String>;>;map.entrySet()Entry
C: <;Map.Entry<;String,Integer>;>;map.keySet()Map.Entry
D: <;Map.Entry<;String,Integer>;>;map.entrySet()Map.Entry
举一反三
- 题示代码的功能为:循环遍历输出Map当中的每一个元素。《插入代码》处应填入的代码是( )Map map=new HashMap(); map.put(“jessica”,100); map.put(“tom”,200); map.put(“den”,300); Set《插入代码1》 set =《插入代码2》; for (《插入代码3》 per : set) { System.out.println(per.getKey() + ":" + per.getValue()); } 未知类型:{'options': ['[Entry] map.keySet() Entry', '[Entry] map.entrySet() Entry', '[Map.Entry<String, Integer]> map.keySet() Map.Entry[String, Integer]', '[Map.Entry<String, Integer]> map.entrySet() Map.Entry[String, Integer]'], 'type': 102}
- 题示代码的功能为:循环遍历输出Map当中的每一个元素。《插入代码》处应填入的代码是( )Map map=new HashMap(); map.put(“jessica”,100); map.put(“tom”,200); map.put(“den”,300); Set《插入代码1》 set =《插入代码2》; for (《插入代码3》 per : set) { System.out.println(per.getKey() + ":" + per.getValue()); } A: <Entry> map.keySet() Entry B: <Entry> map.entrySet() Entry C: <Map.Entry<String, Integer>> map.keySet() Map.Entry<String, Integer> D: <Map.Entry<String, Integer>> map.entrySet() Map.Entry<String, Integer>
- 下列语句正确的是?() A: Map B: Map<> C: HashMap< D: Map<String,String>
- 将Map集合中的键存储到Set集合的方法是( )。 A: get() B: put() C: keySet() D: entrySet()
- List、Set、Map哪个继承自Collection接口,以下说法正确的是() List Map List Map Set List Set Set Map
内容
- 0
List、Set、Map哪个继承自Collection接口,以下说法正确的是( )。 A: List Map B: Set Map C: List Set D: List Map Set
- 1
在Web应用程序中有以下的程序代码,执行后转发到JSP页面Map<String,String> map=new HashMap<String,String>();map.put("key1","String1");map.put("key2","String2");request.setAttribute("user",map);以下选项中的( )可以正确使用EL取得map中的值。 A: ${map.key1} B: ${user.key1} C: ${map["key1"]} D: ${user[key1]}
- 2
下列关于Map集合的使用说法错误的一项是()。 A: Map用put(key,value)方法来添加一个值。 B: Map用get(key)方法获取与key键相关联的值。 C: Map接口的keySet()方法返回一个有序集合。 D: Map接口中的entrySet()方法返回了一个集合对象。
- 3
请阅读下段代码 public static void main(String[] args) { Map<String,String> hashMap = new HashMap<String,String>(); hashMap.put("传智", "播客"); hashMap.put("务实", "创新"); for(Map.Entry<String, String> entry:_________){ String key = entry.getKey(); String value = entry.getValue(); System.out.println("Key:"+key+" Value: "+value); } } 请补全下划线处代码,使main()方法能够正常运行
- 4
HashMap<Integer,String> map = new HashMap( );map.put(1,"one");map.put(2,"two");map.put(3,"three");map.put(1,"four");