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!");
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(); } 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
eis a reference to the instance of theException, likeswould be a reference to an instance ofStringwhen you declare likeString s = "...";. Otherwise you won't be able to reference the exception and learn what's wrong with your codee? Could it be written as some other letter and still work?e. I often useexp, but it's kind of a personal thing. It's just the variable name