title: How to run a loop until an exception is not generated
body: <p>I hava a method called <code>test()</code> that throws an exception.</p>
  
  <p>I want to write a loop that executes as long as it throws an exception, and breaks when it no longer throws an exception.</p>
  
  <p>Can any one hint me on the logic that must be use?</p>
  
  <p>For example I tried,</p>
  
  <pre><code>int i=0;
  while(test())
  {
      i++;
  }
  System.out.println(i);
  </code></pre>