"Hi, Amigo. Yesterday I was a bit tipsy, so I'm afraid I've messed up your tasks. But I hope you won’t be mad at me and will complete them all. It's for your own good. Here they come."
Am I missing something here: In catching checked exceptions, part of the task is "The handleExceptions method should catch and display all the exceptions that occur."
The code throws three different types of exception in three modules, the accepted solution only catches two. Why is RemoteException ignored?
Seems a fare number of folks don't understand the Exceptions paradigm. Basically anyone can create a method that throws some exception type(s), and since we are using other classes in our methods, we need to deal with those exceptions if they do in fact get thrown. At the base of all this are the java class files, like Integer, which will do the actual work for us (i.e. divide by zero), get an error from the system (or maybe it sees the zero and pre-empts it), creates an Exception Object (in this case ArithmeticException), places it in the stack frame where the method is located that it occurred in, and forwards execution to the catch block that catches it's Exception Type (if it can) or one of it's super classes (again, if it can) and if it has no catch block for it's type or any of it's super class types, it looks to throw it up the call stack. If the method where the exception occured has 'throws xxxException' (where xxx is Arithmetic, NullPointer, etc), it will just pass it up the call chain. Using some class's method that throws an exception is instructions to us to either catch it or throw it ourselves, and on up the chain it goes. And if the method where the exception occurred does not have 'throws xxxException' and the method encountered the exception, your program halts.
This was nice tbh. A little bit refreshing, not too hard, not too shabby as well as seems relevant to the course. Learnt a lot and this might definitely be useful in the near future.
I enjoyed the course much more today than yesterday. The reason is that I read the relevant Head First Java chapter first. I think this course needs some complementary reading to help make sense of what's going on. If you have the chance to read Head First or a similar Java basics book, I think you'll find it helpful too.
As others have mentioned, these tasks seemed like a marching order - just follow and do it, you might be told why's and how's later. We are still in the Syntax section, so I get we need to get used to writing them, but without more context of where and how it fits, it's easy to get discouraged. I hope CG will bring it all together in the coming levels to make sense of it all. For now, will just keep on keeping on. Happy coding! :)
Russell Level 9, Galmpton, Brixham , United Kingdom
30 April 2021
yeah i think the reason so many people stop at this point (or indeed at earlier points) is that the tasks (medium and abvove tasks) don't necessarily make any practical sense, why am I configuring an awkward ass program to collect custom exceptions. or random stack traces I need to catch exceptions in my code, yes. but why am I going out of my way to create a new one. Its just me I'm sure but i just cant see a time when application of the medium task would be at all useful. That in itself stops you in your tracks whilst you say to yourself.. "Why The F...?" Then as the code is silly to wrangle, you lose interest and thus lose interest in the course. Its a roadblock. You kind of lose trust in the tasks and thus don't complete them.
Maybe they'll bring together all my knowledge later coherently
SinisaLevel 11, Banja Luka, Bosnia and Herzegovina
15 March 2021
This whole lesson is only complicating things when it comes to beginners (as advanced ones certainly do not attend classes like this one).
You need try/catch when your program has multiple outcomes that can lead to abnormal program termination. So you need to catch one or multiple error messages that JVM throws back to you, or through testing predict what the possible errors may be and how to catch them.
Another thing is difference between throwing/try-catching, ie. what JVM checks, what not.
And that's all, on top of that you further advance your knowledge.
I did all the task on the first or second try but still don't feel like I understood anything :D
I hope I will in the future...
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.
GO TO FULL VERSION