Getting the data from the hashmap (nullpointer exception)
Hi, i got a problem over here, i tried to get the data from the hashmap and put into an array list however, i get nullpointerexception as shown on the code below.. any help will be appreciated thank you
privatevoid getModel1(){
TreeModel m =new DefaultTreeModel(t);
xmlList = testHashmap.toList(t);
Map testMap = testHashmap.toHashMap(t);
String a [] =new String [testMap.size()];
for (int i=0; i<a.length; i++){
a[i] =new String();
a[i] = (String) testMap.get(xmlList.get(i));
System.out.println(a[i]);//null
xmlListElements.add(a[i]);
}
Class Methods
publicstatic HashMap toHashMap(TreeNode tn){
Enumeration e =null ;
e = tn.children();
TreeNode tmp =null;
HashMap map =new HashMap();
while(e.hasMoreElements()){
tmp = (TreeNode)e.nextElement();
map.put(tmp.toString(), toList(tmp));
}
return map;
}
publicstatic List toList(TreeNode tn){
ArrayList l =new ArrayList();
Enumeration e = tn.children();
while(e.hasMoreElements()){
l.add(e.nextElement());
}
return l;
}
>

