
whis is the IllegalStateException in java? or define IllegalStateException with exp?

This error occur due to Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation.
Example1
class ThrowDemonstration
{
static void throwDemonstration( )
{
try
{
throw new IllegalStateException("MyException");
}
catch(IllegalStateException objA)
{
System.out.println("caught:" +objA);
}
}
public static void main(String args[])
{
throwDemonstration( );
}
}
Example2
class ThrowState
{
static void throwdemostration()
{
try
{
throw new IllegalStateException();
}
catch (NullPointerException objetB)
{
System.out.println("Not caught by catch block inside throwdemostration().");
}
}
public static void main(String args[])
{
try
{
throwdemostration();
}
catch(IllegalStateException objetC)
{
System.out.println("Exception Caught in:"+ objetC);
}
}
}