A: map.put(“jim”,map.get(“jim”)+100);
B: map.set(“jim”,map.get(“jim”)+100);
C: map.put(“jim”,234.5);
D: map.set(“jim”,234.5);
举一反三
- 中国大学MOOC: 请看一下代码,《插入代码》处应填入的代码是( )Mapmap=newHashMap();map.put(“tom”,123.6);map.put(“jim”,234.5);map.put(“terry”,45.3);《插入代码》 其中《插入代码》处要实现的功能是把key为“jim”的value值在原有数字的基础上添加100。
- 题示代码的功能为:循环遍历输出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>
- 题示代码的功能为:循环遍历输出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}
- 应用程序的main方法中有以下语句,则输出的结果是 ( )。 HashMap map=new HashMap(); map.put("100","aaa"); map.put("200","bbb"); map.put("300","ccc"); System.out.println(map.get("300").toString()+ map.get("200").toString() + map.get("100").toString());
- HashMap<Integer,String> map = new HashMap( );map.put(1,"one");map.put(2,"two");map.put(3,"three");map.put(1,"four");
内容
- 0
中国大学MOOC: 阅读以下代码,选择正确的选项( )。Hashtable map = new HashMap(); map.put(“name”, “张三”): map.add(“sex”,”男”);System.out.println(map.get(“name”));
- 1
给定如下Java 程序代码片段,编译运行这段代码,结果是( )HashMap map = new HashMap();map.put("name",null);map.put("name","Jack"); System.out.println(map.get("name")); A: null B: Jack C: nullJack D: 运行时出现异常
- 2
下面语句执行后,执行get(1)方法得到的值是() HashMap<Integer,String> map = new HashMap; map.put(1,"one"); map.put(2,"two"); map.put(3,"three"); map.put(1,"four");
- 3
在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]}
- 4
阅读下面的Java代码,运行结果描述正确的是( )。import java.util.*;public class TestMap{public statci void main(String[] args){Map map=new HashMap( ); map.put(“first”,”football”); map.put(“first”,”basketball”); System.out.print(map.get(“first”));}} A: 编译时发生错误 B: 编译通过,运行时发生错误 C: 正确运行,显示basketball D: 正确运行,显示football