Java; null pointer on newly created array with user-defined length
<p>So, right after the public class declaration, I've declared an array as follows:</p>

<pre><code>public String[] accept;
</code></pre>

<p>From here then, I'm looking to take user input to see how long this array should be - and following this, we'd enter into a loop to populate the array with Strings. I put the following into a method;</p>

<pre><code>if (scanner.hasNextInt()) {
wcount = scanner.nextInt();
//create the array.
String accept[] = new String[wcount];
}
System.out.println(accept.length);
</code></pre>

<p>But unfortunately, no nice. Java returns with;</p>

<pre><code>Exception in thread "main" java.lang.NullPointerException
</code></pre>

<p>Obviously, attempting to go straight into a for loop to populate the array, will also give the same results. At first glance, I'm assuming this has something to do with it being initialised as a public array outside of the method itself - but I'm honestly not too sure. Can anyone lend a hand on this?</p>
