The Lone Ortho

Marooned on a secular college campus, I created this blog for the dual purpose of venting and sharing my experiences, pleasant and otherwise. Join me as I traverse the treacherous terrains of galus; it's been a harrowing, yet worthwhile journey thus far. Feel free to partake in the smattering of snide remarks, random Paul Simon references, and utterly ridiculous CS jokes.

Thursday, July 22, 2004

Programming Woes

Today I battled my most dreaded enemy: the NullPointerException.  I was brutally defeated.  My rematch has been scheduled for Monday morning.  Time to come up with a better game plan…hhmm….

7 Comments:

  • At 9:53 AM, Anonymous Anonymous said…

    NullPointerExceptions are a big pain. I've found that you get them a lot when you try to make chained calls, the first of which returns an object that might possibly be null, the second of which tries to get something from the returned object. A good example:

    String s = SomeClass.getBody().toString().

    Since getBody() might return null, the call to toString() will throw a NullPointerException.

    Put try/catch blocks around different parts of your code, and break up compound statements like the one above.

    Greg G.

     
  • At 9:55 AM, Anonymous Anonymous said…

    By the way, can I link to you? I want to post about the Star-K response, and I'd like to give you credit. Don't want to blow your cover, though.

     
  • At 5:45 PM, Blogger Avrom said…

    Hi,

    I make my living as a programmer who writes Java code. Let me just say that NullPointerExceptions are a fact of Java coding life and you will have to get used to them. They are actually not that scary once you get used to them.

    I suggest you do not put them in try/catch blocks as the other comment sugested. If you are expecting the possibility that a method may return a null object, use an if statement.

    Object o= foo.someMethod();
    if (o != null)
    {
    // do something here
    }

     
  • At 9:03 AM, Blogger Keren Perles said…

    C++ rules! Down with Java...
    I can see the commercial:

    The worst part, of wakin' up,
    Is Java's null pointer exceptions!

     
  • At 1:44 PM, Blogger Devorah said…

    Stx, tell the truth. Have you ever programmed in Java???

     
  • At 2:25 AM, Blogger Devorah said…

    This comment has been removed by a blog administrator.

     
  • At 2:26 AM, Blogger Devorah said…

    And if you’re going to go with the commercial, how about…

    The worst part of wakin’ up
    Is Java in your kopp!

     

Post a Comment

<< Home