Is catching a specific exception less expensive than catching a generic one?
<p>Say I'm loading a Bitmap onto my Android device. There are many possible exceptions that can be thrown. For the sake of simplicity let's take <code>NullPointerException</code> and <code>OutOfMemoryError</code>.</p>

<p>Now I have two pieces of code.</p>

<p><b>Code 1</b></p>

<pre><code>try{
//load the bitmap
}
catch(Exception e)
{
//do something
}
</code></pre>

<p><b>Code 2</b></p>

<pre><code>try{
//load the bitmap
catch (NullPointerException e)
{
//do something
}
catch(OutOfMemoryError e)
{
//do something else
}
</code></pre>

<p>Is one piece of code more effective than the other <b>performance</b> wise? If so, why?</p>
