Robert

55%
Flag icon
Note that the doc comment does not say “mod throws NullPointerException if m is null,” even though the method does exactly that, as a byproduct of invoking m.signum(). This exception is documented in the class-level doc comment for the enclosing BigInteger class. The class-level comment applies to all parameters in all of the class’s public methods. This is a good way to avoid the clutter of documenting every NullPointerException on every method individually.
Robert
I would err on documenting it on the method. You have to tailor to real-world behavior, and people will too often not read class documentation, often because it can be very lengthy.java.util.Formatter's class doc is more than 10 pages, and it's the very last line that has this NullPointerException message.
Effective Java
Rate this book
Clear rating
Open Preview