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));

所以问题是必须在选项和/或方法中输入什么才能传递空值?

我尝试了以下代码但没有成功:

 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();

原文由 Neutron_boy 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 351
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题