title: Very large, specific 2d array for-loop returning null values in random spots
body: <p>I have a huge double for loop to fill a 2d array, based on a very specific set of criteria. I'm displaying this 2d array in a JOptionPane; on some runs of the program, I get no "null", on others, I get lots of them. There doesn't appear to be a pattern of where/when it occurs.</p>
  
  <p>This leads me to believe my issue has to deal with my "else if" criteria.</p>
  
  <p>My array is filled with different strings depending on: If there are Monsters in the cell, if there is a piece of Armour, if there is a Weapon, if there is Nothing, or if there is a combination of any assortment of the above (monster + weapon, monster + armour, etc).</p>
  
  <p>This has lead me to make the following chain of if/else if:</p>
  
  <pre><code>if(map[a][b] == map[0][0])      //sets the first cell as the entrance
  ...
  else if(!x.hasAM()  &amp;&amp; armour == 0 &amp;&amp; weapons == 0)         //has nothing
  ...
  else if(!x.hasAM() &amp;&amp; armour &gt; 0 &amp;&amp; weapons == 0)           //has armour
  ...
  else if(!x.hasAM() &amp;&amp; armour == 0 &amp;&amp; weapons &gt; 0)           //has weapon
  ...
  else if(x.hasAM() &amp;&amp; armour == 0 &amp;&amp; weapons == 0)           //has monster
  ...
  else if(x.hasAM() &amp;&amp; armour &gt; 0 &amp;&amp; weapons == 0)        //has monster, has armour
  ...
  else if(x.hasAM() &amp;&amp; armour == 0 &amp;&amp; weapons &gt; 0)        //has monster, has weapon
  ...
  else if(x.hasAM() &amp;&amp; armour &gt; 0 &amp;&amp; weapons &gt; 0)     //has monster, has armour, has weapon
  </code></pre>
  
  <p>In some of these, the way I assign the string is simply "map[a][b] = "|________|";". In others I have nested Switches. I don't think that's the issue, though, because the strings that are generated by the nested Switches work. But obviously I have no clue what the issue is, so just in case here is an example of the most "complex" set up:</p>
  
  <pre><code>else if (Player.type.equalsIgnoreCase("Ranger")) {
      if (Cell.monsters.length == 4) {
          switch (weapons) {
              case 1:
                  switch (armour) {
                      case 1:
                          map[a][b] = "|_!Sl@L__XXXX|";
                          break;
  
                      case 2:
                          map[a][b] = "|_!Sl@C__XXXX|";
                          break;
  
                      case 3:
                          map[a][b] = "|_!Sl@P__XXXX|";
                          break;
  
                      case 4:
                          map[a][b] = "|_!Sl@M__XXXX|";
                          break;
                  }
                  break;
          }
      }
  }
  </code></pre>
  
  <p>The issue I'm having is that sometimes the output of my program is like this:</p>
  
  <pre><code>|_!Sl@M__XXXX| |_!Sl@M__XXXX| null null |_!Sl@M__XXXX|
  null |_!Sl@M__XXXX| |_!Sl@M__XXXX| null null
  </code></pre>
  
  <p>etc.</p>
  
  <p>Here is the full method, in case I'm wrong about it being my "else if" statements and you want to look at the whole thing: <a href="https://gist.github.com/anonymous/7518098" rel="nofollow">https://gist.github.com/anonymous/7518098</a></p>
  
  <p>And as always, thanks in advance! :D</p>