title: Does the length of a newly instantiated array resolve to 0 or null?
body: <p>HOMEWORK: I'm getting and index out-of-bounds on the following code. It's a hangman game, and I'm keeping track of the letters I've guessed in a <code>char</code> array. </p>
  
  <p>Here's the assumptions I made:</p>
  
  <ol>
  <li>In the calling method, I have an unpopulated array (<code>char[] displayGuesses = new char[26];</code>) passing to the method below as the <code>char[] usedLetters</code> parameter. </li>
  <li>The first iteration of the letter-guessing, the array will be empty. </li>
  <li>It's length will be 0. </li>
  <li>I populate <code>usedLetters[0]</code> with the <code>letterGuessed</code> parameter. </li>
  <li><p>The next time I guess, length of the array will be 1, so <code>usedLetters[1]</code> gets populated...and so on.</p>
  
  <pre><code>public char[] trackUsedLetters(char letterGuessed, char[] usedLetters)
  {
      int letterIndex = usedLetters.Length;
      usedLetters[letterIndex] = letterGuessed;  
      return usedLetters;
  }
  </code></pre></li>
  </ol>
  
  <p>There's a couple things I think may be going on. </p>
  
  <ol>
  <li>When I try to get the length of <code>usedLetters</code> on the first run, the empty array does
  NOT return zero, but null. Boom. Out-of-bounds.</li>
  <li>There's some issue with passing a blank array defined with 26
  members...? But I'm not sure what that issue would even BE, so I have no idea what to google that will yield relevant results. </li>
  <li>I may have a scope issue; I found <a href="https://stackoverflow.com/questions/13553014/java-null-pointer-on-newly-created-array-with-user-defined-length">this link</a> to a similar
  question for Java, though using a <code>for</code> loop. I don't <em>quite</em> get
  what the Java user was going for, but some of the problems sounded
  familiar.</li>
  </ol>
  
  <p>I need a second pair of eyes to look at this and point me in the right direction for solving this. </p>