UserDefined Exception

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);
}





}

Comments

Popular posts from this blog

தட்டு வண்டியில் காளிக்கோயில் - சிறுகதை

பிரேமாவின் பெண் குழந்தை

தீபம் பிளக்ஸ்