class UserDefineException
{
void cube(int c) throws Myexception
{
if(c<0 p=""> {
throw new Myexception("c");
}
else
{
int r=c*c*c;
System.out.println("Cube of "+c+" is "+r);
}
}
public static void main(String s[]) throws Myexception
{
try{
UserDefineException e=new UserDefineException();
e.cube(3);
e.cube(-3);
}
catch(Myexception e ){
System.out.println("error is .." +e);
}
}
}
class Myexception extends Exception{
Myexception(String a)
{
super(a);
}
}0>
No comments:
Post a Comment