I am a newbie in programming. I was learning java and I found the try/catch. I understood the and the concept very well but I have a question with the catch sentence: What does the identifier do in the catch sentence?, How does it work? How do I use it?
If you do not understand:
public class Example {
public static void main (String[] args) {
try {
Integer.parseInt("m");
}catch (Exception e) {System.out.println("ERROR");} //This identifier (e)
}
}
Probably the answer is very obvious but i want be sure.
The e
is the exception you should be examining or at least printing so that you know what error occurred, where and possibly why. add
e.printStackTrace();