Coding

Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don't hold it against me. One of the perils of having a 20+ year old website!

This semester I am taking CompSci II, an advanced Java programming course at my school. So I figured I might as well live up to the name of my blog and talk about it. I am not planning on talking about CS I stuff- that is, basic programming- ifs, whiles, fors etc. unless I am asked. I’d also like you to keep in mind that I am still learning the CS II stuff, so if you see something that’s wrong or it doesn’t seem like I fully understand it, feel free to correct me in the comments.
It’s tough to kinda find a starting point for this- so I guess I can go by class. Tonight we did error handling and exceptions. There are 3 types of errors- syntax, logic, and run time. Exception handling is for run time errors, which, if the program is not coded correctly, will make the program crash. This takes away from the robustness of the program, where robustness is the property of reacting “gracefully” (as opposed to “crashing”) when abnormal conditions.
To prevent crashes, making the program more robust, we add exception handling in the form of a try/catch statement. a try/catch statement is set up like this:

try{
-code with possible bugs/errors/exceptions-
}
catch(excetionType1 name){
-how you want to handle the error-
}
catch(excetionType2 name){
-how you want to handle the error-
}
finally{
-statements executed after try and catch sections-
}

The way this is set up, you put code in the try section. If at any time in that code an error occurs (stated in Java as “An exception is thrown”) it will check the catch statements looking for that exception to see how to handle it. Usually, (in my experiences) the exception is simply handled with a print statement stating the error. In the future, I’m sure we will look into how to use exception handling not only to state the error, but also allow the program to keep going, or revert back to before the error. The finally statement will be executed whether or not an exception is thrown.
You can find a list of Java Exceptions here. Once my professor posts his notes on exception handling, I will post them here. Later

Update: Here is that link like I promised.

Similar Posts

  • Wow….

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!So Joe, what did you do today? “O you know, the usual. Spur of the moment trip to Hershey Park, Texas…

  • | |

    My ‘System’

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! Over at College V2, Sean has an ongoing series called What’s Your System, where various people talk about how they…

  • |

    Using GMail for files

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! As a college student I am often bouncing around from PC to PC as I go through my day on…

  • Fixing the Fatal ‘add_rewrite_tag()’ Error

    I’m working on a WordPress little side project where I am registering a new Custom Post Type and Taxonomy and came across this: Fatal error: Call to a member function add_rewrite_tag() on a non-object… After doing a Google Search to try to figure out what the issue is, all I came up with was “disable…

  • | |

    Why you should buy a laptop for college….

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! I just read This- it’s entitled “Why you should not buy a laptop for college. Ok so this post isn’t…

  • Sarah

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!Had an Awesome Lunch

One Comment

Comments are closed.