Problem :
I am facing a problem with the exception handling in Java, following is my code. I am facing compiler error when I try to execute my code. The error is as below:
exception MojException is never thrown in body of corresponding try statement
Below is my code:
public class MyTest {
public static void main(String[] args) throws MyMojException {
// TODO Auto-generated method stub
for(int m=1;m<args.length;m++){
try{
Integer.parseInt(args[m-1]);
}
catch(MyMojException e){
throw new MyMojException("The Bledne dane");
}
try{
WierszTrojkataPascala w = new WierszTrojkataPascala(Integer.parseInt(args[0]));
System.out.println(args[m]+" : "+w.wspolczynnik(Integer.parseInt(args[m])));
}
catch(MojException e){
throw new MojException(args[m]+" "+e.getMessage());
}
}
}
}
And here is the code for MyMojException:
public class MyMojException extends Exception{
MyMojException(String str){
super(str);
}
}
Can anyone suggest solution on my issue?