What is the standard exception to throw in Java for not supported/implemented operations?

java.lang.UnsupportedOperationException

Thrown to indicate that the requested operation is not supported.


Differentiate between the two cases you named:

  • To indicate that the requested operation is not supported and most likely never will, throw an UnsupportedOperationException.

  • To indicate the requested operation has not been implemented yet, choose between this:

    1. Use the NotImplementedException from apache commons-lang which was available in commons-lang2 and has been re-added to commons-lang3 in version 3.2.

    2. Implement your own NotImplementedException.

    3. Throw an UnsupportedOperationException with a message like "Not implemented, yet".


If you create a new (not yet implemented) function in NetBeans, then it generates a method body with the following statement:

throw new java.lang.UnsupportedOperationException("Not supported yet.");

Therefore, I recommend to use the UnsupportedOperationException.

Tags:

Java