IllegalArgumentException

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);
    }
}
IllegalArgumentException

Similar Java Tutorials

Leave a Comment