title: JAVA- how to assign string value to string array dynamically
body: <p>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:</p>
  
  <pre><code>String[] content = null;
  for (int s = 0; s &lt; 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 &lt; 1; i++) {
              st1 = ((org.w3c.dom.Node) nnm.item(i)).getNodeValue().toString();
          }
      }
  
      content[s] = st1;
      //HERE it shows null pointer Exception.
  }  
  </code></pre>
  
  <p>Thanks</p>