IllegalArgumentException is a child class of RunTimeException, Hence it is an unchecked exception. IllegalArgumentException is raised explicitly either by the programmer or API developer to indicate that a method is invoked with an illegal argument.
ForExample-
For Threads in Java, the valid range of thread priority is 1 to 10 but if we try to set thread priority out of the valid range (1 to 10) then we will get RunTimeException-“IllegalArgumentException”.
public class IllegalArgument {
public static void main(String[] args) {
Thread t = new Thread();
t.setPriority(16);
}
}
Similar Java Tutorials
- Odd Even in Java
- Fibonacci Series Java
- Method to print exception information in Java
- Exception Handling by Using try-catch in Java
- Checked Exception vs Unchecked Exception
- Exception Hierarchy in Java
- Java Exception Handling Interview Questions
- final finally finalize in java
- User Defined Exception in Java
- Exception Handling Keyword in Java
- throw throws in Java
- try with multiple catch block in Java