Monday, June 30, 2014

Exception part 1

package Exception;


 class Main1 {
void Method1() throws Exception1 {
String args1[]={"1","2"};
if(args1[0].equals("1")){
throw new Exception1("this is error");
}

}
}


 class Main2 {
void Method1() throws Exception2 {
String args1[]={"1","2"};
if(args1[3].equals("1")){

}

}
}

public class Main {
public static void main(String[] args)  {
Main2 main1=new Main2();
try {
main1.Method1();
} catch (Exception2 e) {
System.out.println(e.getMessage1());
}
System.out.println("continue with message");

}
}

No comments:

Post a Comment