ho una mappacome convertire hashmap a matrice di voci
private HashMap<Character, Integer> map;
voglio convertirlo in serie, ma quando lo faccio/ottengo questo:
Entry<Character, Integer> t = map.entrySet().toArray();
**Type mismatch: cannot convert from Object[] to Map.Entry<Character,Integer>**
Entry<Character, Integer>[] t = null;
map.entrySet().toArray(t);
**Exception in thread "main" java.lang.NullPointerException**
Entry<Character, Integer>[] t = new Entry<Character, Integer>[1];
map.entrySet().toArray(t);
**Cannot create a generic array of Map.Entry<Character,Integer>**
Entry<Character, Integer>[] t = null;
t = map.entrySet().toArray(t);
**Exception in thread "main" java.lang.NullPointerException**
Così come convertire HashMap
a Array
? Nessuna delle risposte trovate in altri argomenti di lavoro.
http://stackoverflow.com/questions/529085/java-how-to-generic-array-creation Il fatto è che è n o possibile creare un array generico come 'Entry []'. Usa invece un 'Elenco >'. –
Natix