Exception — Event catchs plots of normal process on a program. this Event normally are some error. — this Event make a program sto...
Exception— Event catchs plots of normal process on a program. this Event normally are some error.
— this Event make a program stopped abnormal.
there are some examples of errors below :
— ArrayIndexOutOfBounds Exception
occurs when access an array elements not found
— NumberFormat Exception
occurs when try to passing as parameter not number on Integer.parseInt methode
to catch exception in Java, we use try-catch-finally block
we must set statement on a program that can get exception, in try-catch-finally block.
below is an example:
//ExceptionExample.class
public class ExceptionExample
click to download
{
public static void main( String[] args ){
try{
System.out.println( args[1] );
}
catch( ArrayIndexOutOfBoundsException exp ){
System.out.println("Exception caught!");
}
}
}
click to download