What the Null?

Posted: December 16th, 2007 | Author: steve | Filed under: software engineering |

If I’m having a bad day at work there is one website that will always cheer me up: The Daily WTF. It’s full of techy humour and never fails to raise a laugh. These two code snippets are from here, you have to be a developer to appreciate these:

void failIfNull(Object o) throws RuntimeException {
  if (o == null)
  {
    throw new RuntimeException(o.getClass().getName() + " is null!");
  }
}

and…..

// An exception may be thrown before the [...] is fully initialised
if (this.equals(null))
{
  Warning.showWarning((JFrame) null, title, msg);
}
else
{
  Warning.showWarning(this, title, msg);
}


Leave a Reply