
class Myexception extends Exception{
private int detail;
Myexecption(int a){
detail=a;
}
public String toString(){
return "Myexception["+detail+"]";
}
}
class Exceptiondemo{
static void Compute(int a) throws Myexception{
System.out.println("Called compute("+a+")");
if(a>10) throw new Myexception(a);
System.out.println("Normal Exit");
}
public static void main(String args[]){
try{
Compute(1);
Compute(20);
}catch(Myexception e){
System.out.println("Caught"+e);
}
}
}
hi to all please help me friends here i created my own exception(Myexception), but its showing invalid method declaration; return type required for Myexception(int a).and thank in advance friendss. Happy new year
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.