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

  • The Stretch…

    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!With the end of the semester quickly approaching, I am really looking forward to a summer vacation- my last one at…

  • | |

    Casabona.Org

    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!The Official Launch! Im excited to announce, on June 1st, 2005- the official launch of Casabona.Org– a website I have been…

  • |

    Nothing good to say

    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 try not to make this a personal blog. Soon enough I will be blogging about my CS 2 adventures- Level…

  • |

    The Visible Light Spectrum

    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 am taking a Light and Photography course at school where we are learning about the electromagnetic spectrum (EMS) and…

  • |

    Testing your Responsive Site

    Over the last year or so I’ve been involved with a few major projects that required responsive design/development. One of the most important things to remember about a responsive design is that it’s not just good enough to make sure your design shrinks with a smaller browser on your computer. Presumably, you’re doing this because…

  • Types of classes, part 2

    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!Today I will continue my series on classes in Java. To review where we are, you can read this post. First…

One Comment

Comments are closed.