You need to make your HashMap, i.e. to Map[x] = (String Key, Integer Value) , where x is calculated by the lance, for example, Сумма Ascii в Key % Размер Map

I’ve covered everything, I can’t find how to implement Map so that I can manually specify the save location Map[x] = (String Key, Integer Value) .

 Map<String, String> map[] = new Map[3]; map[0].put("1", "Jan"); map[1].put("2", "Feb"); map[2].put("3", "Mar"); 

gives out

 Exception in thread "main" java.lang.NullPointerException at UB4_Anders.HashMapMain.main(HashMapMain.java:36) 
  • map[] is an array of Map type objects. map[0].put is an attempt to add an element to the first Map from this array. Are you sure that this is exactly what you want to do? - Regent
  • no, I’m not sure if I ran into the Map theme for the first time, I need a HashMap [100] for example, where I will insert key / value pairs into positions calculated by the formula List [x] = "Accountant, 1000", where x = 1000% 3 for example - Vladimir
  • If you implement your Map ( public class MyMap<K, V> implements Map<K, V> { ... } ) and want to make a special way of adding a key-value pair, then besides the public V put(K key, V value) method public V put(K key, V value) to do a separate method (for example, public V put(int keyCode, K key, V value) ). - Regent

0