简体   繁体   中英

InterruptedException e

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?

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 .

It is irrelevant. It is just a variable name. You can name the exception anything.

catch(Exception someVariableNameYouChoose)

That is just an name for your exception object. You can have "kokoobananas" in place of "e" :). Just make sure you use kokoobananas.printStackTrace()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM