class MyExp extends Exception
{
public MyExp(String msg)
{
System.out.println(msg);
}
}
public class throws1 {
static int mtd(int a,int b) throws MyExp
{
if(b==0) throw new MyExp("Example for throw b") ;
else
if(a==0) throw new MyExp("Example for throw a") ;
return a/b;
}
public static void main(String args[])
{
try
{
System.out.print(mtd(10,0));
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment