If without else not running <p>I have a little code for testing a sprite, that I want to move with the mouse. When I click the screen, the sprite has to move to the clicked point. But something weird is going on.</p> <p>I'm running it in a thread, called Controls, that extends to Thread and implements MouseListener, and using the following code, the sprite moves.</p> <pre><code>public void run() { while(true){ if((int)point.getX() &gt; player.getX()){ while((int)point.getX() &gt; player.getX()){ player.moveX(1); } } else{ System.out.println("Nah!"); } } } </code></pre> <p>Everything works as expected, but if i do this:</p> <pre><code>public void run() { while(true){ if((int)point.getX() &gt; player.getX()){ while((int)point.getX() &gt; player.getX()){ player.moveX(1); } } } } </code></pre> <p>It doesn't work. If i do this:</p> <pre><code>public void run() { while(true){ if((int)point.getX() &gt; player.getX()){ while((int)point.getX() &gt; player.getX()){ player.moveX(1); } } else{ } } } </code></pre> <p>It doesn't work either. I have no idea of what is going on, any ideas?</p>