Java Mappings and Primitives
问题 I want to create a mapping that takes a String as the key and a primitive as the value. I was looking at the Java docs and did not see that Primitive was a class type, or that they shared some kind of wrapping class. How can I constrain the value to be a primitive? Map<String, Primitive> map = new HashMap<String, Primitive>(); 回答1: Java Autoboxing allows to create maps on Long, Integer, Double and then operate them using primitive values. For example: java.util.HashMap<String, Integer> map =