Thomas Sundberg

July 28, 2011

Do not return null

This post is available at


  1. Good point. But isn’t java.lang.UnsupportedOperation the standard exception to use for not implemented methods?

    Comment by Peter Koller — July 29, 2011 @ 18:42

    • You might be right. But then again, not supported isn’t really what I want to express. The operation is supposed to be supported, it just hasn’t been implemented yet.

      Comment by Thomas Sundberg — July 29, 2011 @ 19:22

  2. Thanks a lot.. Changing the IntelliJ behavior saved me lot of repetitive work :). You can remove the #if check, so that methods with void type also throw exception.

    Comment by tom — March 28, 2015 @ 01:56

    • Hi!

      You are absolutely right, removing the #if and keep the throw is a good suggestion.

      I took a look at my current Idea settings and realized that that is the exact implementation I use myself. So, I implement this as

      throw new NotImplementedException();

      and nothing more.


      Comment by Thomas Sundberg — March 28, 2015 @ 11:08

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: