hm.put("billingEnquiry",true);
产生错误
The method put(Object, Object) in the type HashMap is not applicable for the arguments
(String,boolean)".
如何解决这个问题?
hm.put("billingEnquiry",Boolean.TRUE);
boolean
小写 b 是原语而不是对象。
您可能正在使用非参数化的 HashMap。尝试像这样声明您的 HashMap:
HashMap<String, Boolean> myMap = new HashMap<String, Boolean>();
另请注意,您不能在泛型类型中使用原始类型。所以这:
HashMap<String, boolean> myMap = new HashMap<String, boolean>();
...是不正确的,甚至不会编译。