小编Neu*_*boy的帖子

HashMaps和Null值?

如何将空值传递给HashMap?
以下代码段适用于填写的选项:

HashMap<String, String> options = new HashMap<String, String>();  
options.put("name", "value");
Person person = sample.searchPerson(options);  
System.out.println(Person.getResult().get(o).get(Id));    
Run Code Online (Sandbox Code Playgroud)

那么问题是必须输入选项和/或传递空值的方法?
我尝试了以下代码但没有成功:

options.put(null, null);  
Person person = sample.searchPerson(null);    

options.put(" ", " ");  
Person person = sample.searchPerson(null);    

options.put("name", " ");  
Person person = sample.searchPerson(null);  

options.put();  
Person person = sample.searchPerson();    
Run Code Online (Sandbox Code Playgroud)

java null hashmap hashcode

56
推荐指数
2
解决办法
16万
查看次数

标签 统计

hashcode ×1

hashmap ×1

java ×1

null ×1