I get the following error when trying to compile an example from the book.
MyEx.java:5: class ExTestDrive is coderanch, should be declared in a file named ExTestDrive.java
public class ExTestDrive {
^
1 error
Here is the example.
class MyEx extends Exception { }
public class ExTestDrive {
public static void main(
String[] args) {
String
test = args[0];
try {
System.out.print("t");
doRisky(test);
System.out.print("o");
} catch (MyEx e) {
System.out.print("a");
} finally {
System.out.print("w");
}
System.out.print("s");
}
static void doRisky(String t) throws MyEx {
System.out.print("h");
if ("yes".equals(t)) {
throw new MyEx();
}
System.out.print("r");
}
}