static void throwMethod() throws IllegalAccessException {  
       System.out.println("Inside throwMethod.");   
}

解决方案 »

  1.   

    public class ThrowsDemo {
          static void throwMethod() throws IllegalAccessException{
                  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);
               }
           }
    }这样就好了嘛!
      

  2.   

    或者:static void throwMethod() throws IllegalAccessException {  
           System.out.println("Inside throwMethod.");  
           throw new IllegalAccessException("demo");   
    }