IllegalArgumentException or NullPointerException for a null parameter? [closed]
You should be using IllegalArgumentException (IAE), not NullPointerException (NPE) for the following reasons: First, the NPE JavaDoc explicitly lists the cases where NPE is appropriate. Notice that all of them are thrown by the runtime when null is used inappropriately. In contrast, the IAE JavaDoc couldn’t be more clear: “Thrown to indicate that a method … Read more