Reputation: 11
I'm reading about InterruptedException
because I'm dealing with threads, and I'm wondering is the catch (InterruptedException e)
a special case because there is an e
there?
I've seen ie
, but unfortunately I can't seem to find any webpage that tells me what the letters after InterruptedException
do.
Are there different InterruptedException
s?
Upvotes: 1
Views: 295
Reputation: 2300
That is just an name for your exception object. You can have "kokoobananas" in place of "e" :). Just make sure you use kokoobananas.printStackTrace()
Upvotes: 0
Reputation: 5087
It is irrelevant. It is just a variable name. You can name the exception anything.
catch(Exception someVariableNameYouChoose)
Upvotes: 0
Reputation: 85789
No, they're not. The e
or ie
after InterruptedException
is just the name of the variable where the exception raised will be caught.
This piece of code:
try {
} catch (InterruptedException e) {
e.printStackTrace();
}
And
try {
} catch (InterruptedException ie) {
ie.printStackTrace();
}
Are basically the same. The only difference is the name of the variable, the former declares it as e
while the latter declares it as ie
.
Upvotes: 4