I am getting error as below why ....... what is the solution ......
---------- Javac ----------
primk.java:6: unreported exception java.lang.IllegalAccessException; must be caught or declared to be thrown
throw new IllegalAccessException("demo");
^
primk.java:14: exception java.lang.IllegalAccessException is never thrown in body of corresponding try statement
catch (IllegalAccessException e)
^
2 errors
-----------------------------------
public class primk
{
static void throwMethod()
{
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}
public static void main(
String args[])
{
try
{
throwMethod();
}
catch (IllegalAccessException e)
{
System.out.println("Caught " + e);
}
}
}