In my application i got string values dynamically. I want to assign these values to string array then print those values.But it shows an error(Null pointer exception) EX:
String[] content = null;
for (int s = 0; s < lst.getLength(); s++) {
String st1 = null;
org.w3c.dom.Node nd = lst.item(s);
if (nd.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
NamedNodeMap nnm = nd.getAttributes();
for (int i = 0; i < 1; i++) {
st1 = ((org.w3c.dom.Node) nnm.item(i)).getNodeValue().toString();
}
}
content[s] = st1;
//HERE it shows null pointer Exception.
}
Thanks
for
loop(int i = 0; i < 1; i++)
is telling it to do this loop once. That is a bit unusual. You could delete the loop and leave the contents inside and achieve the same results. – Chad Bingham Sep 29 '13 at 18:52