Multiple tasks about multi-catch
Comments (47)
- Popular
- New
- Old
You must be signed in to leave a comment
Michael Amann Full Stack Developer
15 May 2022, 22:33
I smoked this section!
+2
Anonymous #10960894
31 March 2022, 11:08
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?
0
Andrés Sebastián López
11 October 2022, 18:08
I don't know if I am right, but RMI is for Remote Method Invocation, and that means an exception can be thrwon from a remote virtual machine. So, what I understand -and just a little because I'm really noob- is that RemoteException would throw the other two exceptions because you are working with same solution, so other two exceptions are also caught.
Again, I don't know if what I'm saying it's correct...
0
Jonaskinny Java Developer at Sandmedia
20 February 2022, 12:21
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.
0
Stanislav Mayer
6 February 2022, 21:28
I find the instructions for the last task (We're all friends here, even the exceptions) extremely confusing. And the "Hint" makes it even worse.
0
whoseunassailable Backend Developer
2 February 2022, 10:39
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.
+1
Anonymous #10775689
2 August 2021, 16:20
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.
+5
Stanislav Mayer
6 February 2022, 08:56
I apply quite an opposite approach: CodeGym learning first, then (if needed) Head First. And it works for me very well. Everyone needs to find what suits them the best, I guess.
Nevertheless, it is very nice of CodeGym team that they recommended studying the Head First in 1-9 Chapter already!
0
ImDevin
9 May 2021, 17:47
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! :)
+3
Russell
30 April 2021, 16:24
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
+4
Sinisa
15 March 2021, 14:30
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.
+1
Jurij Thmsn
29 January 2021, 17:21
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...
0