question on this java code segment
<p>The following code is claimed to use a do loop with a flag to repeat input until a valid int is obtained.</p>

<pre><code> do
{      
  try
  {
    // attempt to convert the String to an int
    n = Integer.parseInt( s );
    goodInput = true;
  }
  catch ( NumberFormatException nfe )
  {
    s = JOptionPane.showInputDialog( null,
            s + " is not an integer. Enter an integer" );
  }
} while ( !goodInput );
</code></pre>

<p>I am a little confusing about the logic here. If the Integer.parseInt just works fine, or there is no exception occuring, then the "goodInput" is assigned to "true" at line of </p>

<pre><code> goodInput = true;
</code></pre>

<p>Then the !goodInput will be evaluated as False, so the while loop will continue again. This seems to me contradicts to the designed logic, i.e., the while loop should stop after performing a correct parse operation. What is wrong with my analysis above. </p>
