I recently finished the chapter on exceptions in "thinking in java" and "sams java in 21 days" I understand the idea's of using it, but I am still a little confused and I come here looking for help with understanding it.
I get that it's to protect your code, but I just don't see when it becomes important to use. Is it generally expected to use exceptions to exit the program and report where and what happened, or is it to keep the program from exiting and continuing as expected? I have a hard time putting into words what confuses me about exceptions. In sams java 21 it was used to restrict users from entering certain numbers, and most of the examples in thinking in java are more about where it goes when an exception is thrown, and not many practical examples, for most of the book I don't enjoy this type of examples, but in this chapter it seems to be good. Has anyone out there had trouble learning exceptions, and how did you finally manage to understand how they work?
I understand that you are supposed to guard your code statements with a try catch clause, that way if something happens the code will throw an exception and you can write more code to catch it and manage it, but I don't really get why it's useful to use.