I am trying to pull the values from hash map and put them in array, but I keep getting a null pointer exception.
Is there any other way to do this?
//some code....
String n[]=new String[tcur.getCount()];;
String t[]=new String[tcur.getCount()];;
HashMap<Integer, String> typehashmap=new HashMap<Integer, String>();
HashMap<Integer, String> namehashmap=new HashMap<Integer, String>();
//some code..
String type[]=typehashmap.keySet().toArray(new String[typehashmap.size()]);
String name[]=namehashmap.keySet().toArray(new String[namehashmap.size()]);
for (int i=0;i<=type.length;i++) {
n[i]=namehashmap.get(nameiterator[i]).toString();
System.out.println(n[i]);
t[i]=typehashmap.get(typeiterator[i]).toString();
System.out.println (t[i]);
}
Why don’t you use this?
You can work with values collection many ways.
If you still want arrays, maybe you want do: