Latest News

 










Exception Handling Example

Previous slide Next slide Back to first slide View graphic version


Exception Handling Example


 
My other sites

Latest News

 










Exception Handling Example

    public class ExceptionExample {
    public static void main (String[] argv) {
    int [] numArray; // declaration
    numArray = new int[10]; // creation
    try {
    for (int x=0; x<numArray.length +1; x++) {
    numArray[x] = x * 2;
    System.out.print(numArray[x] + ":");
    }
    }
    catch (ArrayIndexOutOfBoundsException ex) {
    System.out.println("Array Exception caught!!");
    }
    finally {
    System.out.println("Reached finally clause");
    }
    }
    }

    Causes the
    Exception

Previous slide Next slide Back to first slide View graphic version