Use Integer
instead.
HashMap<Integer, MyObject> myMap = new HashMap<Integer, MyObject>();
Java will automatically autobox your int
primitive values to Integer
objects.
Read more about autoboxing from Oracle Java documentations.
More Related Contents:
- How to put HashMap into different elements with same key
- Get ArrayList entry of a HashMap Entry [closed]
- What are the differences between a HashMap and a Hashtable in Java?
- Java Hashmap: How to get key from value?
- How to loop through a HashMap in JSP?
- How can I convert JSON to a HashMap using Gson?
- How to sort a HashMap in Java [duplicate]
- Sorting HashMap by values [duplicate]
- What happens when a duplicate key is put into a HashMap?
- Is a HashMap thread-safe for different keys?
- How to update a value, given a key in a hashmap?
- What is the significance of load factor in HashMap?
- Why there is no ConcurrentHashSet against ConcurrentHashMap
- Can an array be used as a HashMap key?
- How can I combine two HashMap objects containing the same types?
- Sorting hashmap based on keys
- What is the optimal capacity and load factor for a fixed-size HashMap?
- HashMap implementation in Java. How does the bucket index calculation work?
- HashMap to return default value for non-found keys?
- How to copy HashMap (not shallow copy) in Java
- Limiting the max size of a HashMap in Java
- Why does HashMap require that the initial capacity be a power of two?
- Java: how to convert HashMap to array
- Android – Get value from HashMap
- get string value from HashMap depending on key name
- JDK 8 – “The type java.util.Map$Entry cannot be resolved” [duplicate]
- Theoretical limit for number of keys (objects) that can be stored in a HashMap?
- what is the best way to get a sub HashMap based on a list of Keys?
- What is the Java equivalent of Objective-C’s NSDictionary?
- Is Java HashMap.clear() and remove() memory effective?