HashMap中的put如何才可以实现System.out.println("将map集合中添加:"+map.put(8
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/06/13 23:16:00
HashMap中的put如何才可以实现System.out.println("将map集合中添加:"+map.put(8,"李明"));显示加入的内
Map map = new HashMap();//Map是接口,所以Map不可以实例化,即不可以new Map()
map.put(1,"李明");
System.out.println("将map集合中添加:"+map.put(2,"李明"));
怎么实现输出语句中输出是的我用put加进去的内容?我现在运行显示的是null
Map map = new HashMap();//Map是接口,所以Map不可以实例化,即不可以new Map()
map.put(1,"李明");
System.out.println("将map集合中添加:"+map.put(2,"李明"));
怎么实现输出语句中输出是的我用put加进去的内容?我现在运行显示的是null
![HashMap中的put如何才可以实现System.out.println(](/uploads/image/z/1736919-63-9.jpg?t=HashMap%E4%B8%AD%E7%9A%84put%E5%A6%82%E4%BD%95%E6%89%8D%E5%8F%AF%E4%BB%A5%E5%AE%9E%E7%8E%B0System.out.println%28%22%E5%B0%86map%E9%9B%86%E5%90%88%E4%B8%AD%E6%B7%BB%E5%8A%A0%EF%BC%9A%22%2Bmap.put%288)
哥们.你这个问题问的可以.
String name = "李明";
map.put(2,name);
System.out.println("将map集合中添加:"+name);
再问: 不是put的方法原型是public V put(K key,V value)么?那么map.put(1, "李明")就应该返回是String类型啊!按理说应该就是返回的”李明“ 为什么会是空呢? 我问的是这个意思,不是纯粹为了显示我加进去的是什么内容!
再答: 你文档看的不仔细。。别猜结果。 设计者也知道你放进去的东西不用再给你反回来。因为你放进去的东西你当然知道是什么,他返回给你是没有意义的。 这个方法的返回值,是这个key以前对应的value。 你之前没有过这个key,所以这个方法返回了null。
String name = "李明";
map.put(2,name);
System.out.println("将map集合中添加:"+name);
再问: 不是put的方法原型是public V put(K key,V value)么?那么map.put(1, "李明")就应该返回是String类型啊!按理说应该就是返回的”李明“ 为什么会是空呢? 我问的是这个意思,不是纯粹为了显示我加进去的是什么内容!
再答: 你文档看的不仔细。。别猜结果。 设计者也知道你放进去的东西不用再给你反回来。因为你放进去的东西你当然知道是什么,他返回给你是没有意义的。 这个方法的返回值,是这个key以前对应的value。 你之前没有过这个key,所以这个方法返回了null。
HashMap中的put如何才可以实现System.out.println("将map集合中添加:"+map.put(8
JSP声明了一个hashmap(Map map = new HashMap),put了3个键值,问 out.print(
Map map = new HashMap(); map.put("first","football"); map.pu
Map map=new HashMap();
java 中System.out.println()是什么意思?
hashmap和map的区别
Map m = new HashMap(); m.put("a",b); 其中a是随便命名的吗?b是指对象吗?
请问Map map=new HashMap(); 为什么是这样,而不是Map map=new Map();
java中的“System.out.println“和“System.err.println”的区别是什么
HashMap map= new HashMap(); Hashmap map=null;有什么区别?
System.out.write和System.out.println
system.out.println是什么意思啊.