package com;
public class TestFinalChile {
int i = 10;
public int divide(int a)
{
int c;
try{
c= i/a;
System.out.println("The input numbers are "+i +"and"+a);
}
catch(ArithmeticException e)
{
System.out.println("You are trying to divide a number by zero. It is not valid");
c = i*a;
System.out.println(c);
}
finally
{
System.out.println("The input numbers are from finally "+i +" and "+a);
}
System.out.println("Outside try and catch");
return c;
}
public static void main(String args[])
{
TestFinalChile test = new TestFinalChile();
test.divide(1);
}
}
public class TestFinalChile {
int i = 10;
public int divide(int a)
{
int c;
try{
c= i/a;
System.out.println("The input numbers are "+i +"and"+a);
}
catch(ArithmeticException e)
{
System.out.println("You are trying to divide a number by zero. It is not valid");
c = i*a;
System.out.println(c);
}
finally
{
System.out.println("The input numbers are from finally "+i +" and "+a);
}
System.out.println("Outside try and catch");
return c;
}
public static void main(String args[])
{
TestFinalChile test = new TestFinalChile();
test.divide(1);
}
}
No comments:
Post a Comment