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;

}

>

[2131 byte] By [Alandera] at [2007-11-27 4:37:42]
# 1
Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and http://www.yoda.arachsys.com/java/newsgroups.html
hiwaa at 2007-7-12 9:48:01 > top of Java-index,Java Essentials,Java Programming...