【发布时间】:2018-07-03 04:25:20
【问题描述】:
是否可以像这样填充 hashmap?
final HashMap<String, String> map = new HashMap<>();
map.put("path", path);
map.put("tableName", "table");
map.put("fileType", fileType);
final HashMap<String, String> option = new HashMap<>();
map.put("option", option.put("header", "true"));
或者还有比这更正确(或更好)的方法吗?因为当我尝试打印“地图”时,关键的“选项”没有任何价值。
提前致谢
【问题讨论】:
-
您定义您的
map是HashMap<String, String>。但是你把option- 一个HashMap<String, String>放到你的map上。那是你的问题。 -
我想将 hashmap 作为一个值放在 hashmap 中,但也与字符串结合作为一个值 @SonhnLab
-
使用
HashMap<String, Object>。