title: Java "foreach" not working...nullPointerException
body: <pre><code>Point bl = new Point(Guy.x, Guy.y + Guy.height);
  Point br = new Point(Guy.x + Guy.width, Guy.y + Guy.height);
  
  for(Tile p: platforms){
              if (p.y == br.y &amp;&amp; br.x &gt;= p.x &amp;&amp; bl.x &lt;= p.x + p.width) {
                  isOnPlatform = true;
              }else{
                  isOnPlatform = false;
              }
  
     }
  </code></pre>
  
  <p>The console says "NullPointerException" when I run that piece of code. Why isn't this working?</p>
  
  <p>I already defined/initalized the variable <code>Tile[] platforms</code>. Also, when I run it, the <code>Guy</code> isn't falling down.</p>
  
  <p>Also, when I do this, it works:</p>
  
  <pre><code>//for(Tile p: platforms){
      if (platforms[1].y  == br.y &amp;&amp; br.x &gt;= platforms[1].x &amp;&amp; bl.x &lt;= platforms[1].x + platforms[1].width) {
                  isOnPlatform = true;
              }else{
                  isOnPlatform = false;
              }
  
   //  }
  </code></pre>
  
  <p>But, I have 2 other <code>platforms</code> and I will add like 20 more. I don't want to have to do that to every <code>platforms</code>.</p>
  
  <p>Any thoughts?</p>