How to deal with a NullPointerException when outputing an array of objects as strings?
<p>When I try to output the strings from the modules </p>

<pre><code>public class Module
{
public String moduleName;
 //public String moduleResults;

 public void setModuleName(String aModuleName)
 {
    moduleName = aModuleName;
 }
 public String getModuleName()
 {
    return moduleName;   
 }
}
</code></pre>

<p>using </p>

<pre><code>public void displayModules()
 {
    for (int i = 0; i &lt; moduleArray.length; i++)
    {
        System.out.println(moduleArray[i].getModuleName());  
    }        
 }
</code></pre>

<p>I get a NPE when the array(of length 4) is not full and when it is full nothing is outputted when I use the method. I'm using blueJ if that makes a difference.</p>
