An exception that indicates that the arguments supplied to a method or function are not valid for their intended purpose, or are different to the format expected by the method.
An exception that indicates that the arguments supplied to a method or function are not valid for their intended purpose, or are different to the format expected by the method.
This could occur as a result of many different actions, such as...
- You are calling a method that accepts a low-level object type for an argument (such as
Object
) but you're passing an object that is not one of the types expected by the method. For example, the method might be declaring the argument as anObject
so that it can capture a range of different objects in the one method, but the code implementation of the method only allows objects of certain types (such as expecting aNumber
-based object, and you're passing aString
). - You're using methods that are building a dynamic structure for use in a different context, and the argument that you're passing is not valid for the other context. For example, you might be building an SQL statement, and you're passing an argument as a
String
for a database field that expects aNumber
. The database context would detect the error and report back the exception.
This type of exception may be hard to predict, as it won't be detected at compile-time, and may only show up under certain circumstances.