/*
 * @topic T11374 Exception demo I
 * @brief ArithmeticException, try-catch-finally
*/

package exceptions;

public class ExceptionsMain {
    public static void main(String[] args) {
        int x = 1;
        int y = 1;
        int z = -1;
        try {
            z = x / y;
        } catch ( ArithmeticException ex ) {
            System.out.println( "first division by zero!" );
            return;
        } finally {
            System.out.println( "first time z is " + z );
        }
        
        y = 0;
        try {
            z = divide( x, y );
        } catch ( ArithmeticException ex ) {
            System.out.println( "second division by zero!" );
        } finally {
            System.out.println( "second time z is " + z );
        }
    }

    public static int divide( int x, int y ) {
        return x / y;
    }

}//class ExceptionsMain