![]() ![]() Have a look at code snipped below, all of the code in the method should be part of the "try code block". Wrap all of the code inside of the method named open File() with a try clause. Do the following to handle this exception. The error message will tell you which exception has been generated, you can check the Java API to get a better understanding about the specific exception. Explore the stack printed out, notice the line where the program encounter a problem. First run the code and select the option number 1, the program will crash. Handling Errors of type FileNotFoundException You will add a try-catch clause to the method named open File(). The exception type being caught must match that one being throw ![]() Wrap all of the code inside of the method named openFile() with a try clause. Handling Errors of type FileNotFoundException You will add a try-catch clause to the method named open Filet). Your goal is to catch those errors, so that the program does not crash. The java program ABuggy Program has four intentional errors. Right now the code does not handle any exceptions, when you call any of the methods, the program will crash and print out the stack. Open the java file and explore it, have a look at the switch and the methods being called inside of the cases.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |