Sunday, June 10, 2012

Is there anything like .NET"s NotImplementedException in Java?

Is there anything like .net's NotImplementedException in java?

Source: Tips4all


  1. Commons Lang has it:

    Or you could throw a UnsupportedOperationException -

  2. I think the UnsupportedOperationException is what you are looking for.

  3. You could do it yourself (thats what I did) - in order to not be bothered with exception handling, you simply extend the RuntimeException, your class could look something like this:

    public class NotImplementedException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public NotImplementedException(){}

    You could extend it to take a message - but if you use the method as I do (that is, as a reminder, that there is still something to be implemented), then usually there is no need for additional messages.

    I dare say, that I only use this method, while I am in the process of developing a system, makes it easier for me to not lose track of which methods are still not implemented properly :)