class MyMadeException extends Exception{}
class ExceptionExample
{
public static void main(String[] args)
{
String test = args[0];
try
{
System.out.println ("First");
doriskyJob(test);
System.out.println ("Forth");
} catch (MyMadeException e){
System.out.println ("Nothing");
}finally{
System.out.println ("Fifth");
}
System.out.println ("Sixth");
}
static void doriskyJob (String t) throws MyMadeException{
System.out.println ("Second");
if ("yes".equals(t)){
throw new MyMadeException();
}
System.out.println ("Third");
}
}
c:\yourjavadir> javac ExceptionExample.java
c:\yourjavadir> javac ExceptionExample Second
First
Second
Third
Forth
Fifth
Sixth
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.