<p>I have an <strong>if</strong> condition which checks for value and the it throws new <strong>NumberFormatException</strong></p>

<p>Is there any other way to code this</p>

<pre><code>if (foo)
{
    throw new NumberFormatException
}

// ..

catch (NumberFormatException exc)
{
    // some msg...
}
</code></pre>

If your aim is to avoid to throw a new exception:
```
```
if(foo)
{
  //some msg...
} else
{
  //do something else
}
```
```