List of utility methods to do HashMap Create
HashMap | newHashMap(K[] keys, V[] values) new Hash Map if (keys.length > values.length) { throw new IllegalArgumentException("Values is less than keys"); HashMap<K, V> map = new HashMap<>(); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); return map; ... |
Map | newHashMap(Map.Entry new Hash Map Map<K, V> map = new HashMap<K, V>(); for (Map.Entry<K, V> entry : entries) { map.put(entry.getKey(), entry.getValue()); return map; |
HashMap | newHashMap(Map extends K, ? extends V> m) new Hash Map return new HashMap<K, V>(m); |
HashMap | newHashMap(Object... kv) Construct a new HashMap with a list of key/value pairs as arguments. int length = kv.length; if (length % 2 != 0) throw new IllegalArgumentException("Mismatched keys and values"); HashMap<K, V> m = new HashMap<>(); fillMap(m, kv); return m; |
Map | newHashMap(T key, U value) new Hash Map Map<T, U> m = new HashMap<T, U>(); m.put(key, value); return m; |
HashMap | newHashMapWithCapacity(int expectedSize, float loadFactor) new Hash Map With Capacity int finalSize = (int) ((double) expectedSize / loadFactor + 1.0F); return new HashMap<K, V>(finalSize, loadFactor); |
Map | toHashMap(Entry to Hash Map return populate(new HashMap<String, String>(), entries); |
HashMap | toHashMap(ArrayList to Hash Map HashMap<String, Integer> map = new HashMap<String, Integer>(list.size()); for (int i = 0; i < list.size(); i++) map.put(list.get(i), i + beginId); return map; |
HashMap | toHashMap(final Map to Hash Map if (map instanceof HashMap) { return (HashMap<K, V>) map; } else { return new HashMap<>(map); |
HashMap | toHashMapStrObj(Object object) replacement of casting as from Object to HashMap<String, Object> without annoying warning. if (object == null) { return null; return (HashMap<String, Object>) object; |