What happens when a for loop has no increment expression in Java?
<p><strong>I found that I had a return statement inside my loop. Thanks for the help anyways everyone.</strong></p>

<p>I have come across a for loop in Java that does not have an increment/decrement expression. As a matter of fact, my IDE tells me that the expression is dead code.</p>

<p>Loop without the increment/decrement expression:</p>

<pre><code>for(int i = 5; i!=0;)
  //Do something...
</code></pre>

<p>Then whenever I try to add <code>i--</code> like so:</p>

<pre><code>for(int i = 5; i!=0; i--)
</code></pre>

<p>My IDE tells me that <code>i--</code> is dead code, which confuses me, as I do not see how I will change. So my question is, how does this loop work in Java? Is this an infinite loop? Does the JVM decrement <code>i</code> on it's own? Etc...</p>

<p>Minimal Example:</p>

<pre><code>for(int i=10; i!=0;i--)
  //Do something...
</code></pre>

<p>Complete:</p>

<pre><code>public void methodName(int number){
  for(int i = number; i!=0; i--)
    //Do something...
</code></pre>