title: In Java, how do I initialize an array of strings?
body: <p>What I want to do is initialize an array of strings and then fill each space with a different string, like so:</p>
  
  <pre><code>        int year = 1995; //the current year i'm working with
  
          String[] Year; //Initialize the year string
          String j;
  
  
          for(int i=(year-50); i &lt; year; i++)
          {
              j = Integer.toString(i); //Converts the integer to a string
              Year[i] = j; //EXCEPTION OCCURS HERE WHEN I SET 'String[] Year'
                           //equal to 'null'
  
          }
  </code></pre>
  
  <p>The problem is that I can't initialize the string because I get the following error:
  'The local variable Year may not have been initialized'</p>
  
  <p>If I set <code>String[] Year = null</code>, then I can initialize the string. HOWEVER, if I do that,  an exception is thrown when attempting to run &amp; compile the code: <code>java.lang.NullPointerException</code></p>
  
  <p>I know that my code could be shorter, but I am trying to isolate the problem...</p>