Reputation: 249
What does the e
mean in the following code?
try {
// Do something
} catch (Exception e) {
// Do something
}
I've been researching and have gotten nothing.
System.out.println("Thanks!");
Upvotes: 5
Views: 17742
Reputation: 24
It is a object which contain info about an error happend. Inherit from throwable and give you a clear message of why your code went wrong
More info
Upvotes: 1
Reputation: 201507
It's a variable name. Exception
is the type. e
is the name. You can use a different name. You might display a message to the user (or a stack trace).
try {
// Do something
} catch (Exception ohNo) {
System.out.printf("Caught exception %s doing something.%n", ohNo.toString());
ohNo.printStackTrace();
}
Upvotes: 10