What the Null?

by admin on July 23, 2009 · 0 comments

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);
}

Next post: