title: java: Bad Time with methods, not returning what it´s supposed too.
body: <p>I´ve been debugging this for hours now. Detecting collision. this code bellow works fine.</p>
  
  <pre><code>while (numberOfTurns &gt;= 0)                                      
              {   
          GObject collision = getElementAt(ball.getX(),ball.getY());
          }
  </code></pre>
  
  <p>It will get any graphical object the ball collides with on screen and return it. However, this is not how I want to design the program. But instead make a seperate method for collision detection, like bellow:</p>
  
  <pre><code>    while (numberOfTurns &gt;= 0)                                      
          {   
          getCollidingObject();
          }
  </code></pre>
  
  <p>Here is the method, it just returns itself</p>
  
  <pre><code>private GObject getCollidingObject()
  {       
      return getElementAt (ball.getX(),ball.getY());
  }
  </code></pre>
  
  <p>then I assign it to this private instance variable</p>
  
  <pre><code>private GObject collider = getCollidingObject();
  </code></pre>
  
  <p>But!!! it does not work, it just returns null. the first code snippet i posted works fine... anyone knows what is happening here?</p>