Thursday, November 17, 2011

Statement Control » throws signature

throws Exception from method

class ThrowsDemo {
  static void throwOne() throws IllegalAccessException {
    System.out.println("Inside throwOne.");
    throw new IllegalAccessException("demo");
  }

  public static void main(String args[]) {
    try {
      throwOne();
    catch (IllegalAccessException e) {
      System.out.println("Caught " + e);
    }
  }
}


http://www.java2s.com/Tutorial/Java/0080__Statement
-Control/Catalog0080__Statement-Control.htm

No comments:

Post a Comment