📄 lostmessage18.java
字号:
// exceptions/LostMessage18.java
// TIJ4 Chapter Exceptions, Exercise 18, page 479
// Add a second level of exception loss to LostMessage.java so that the
// HoHumException is itself replaced by a third exception.
class VeryImportantException extends Exception {
public String toString() {
return "A very important exception!";
}
}
class HoHumException extends Exception {
public String toString() {
return "A trivial exception";
}
}
class MeaninglessException extends Exception {
public String toString() {
return "A meaningless exception";
}
}
public class LostMessage18 {
void f() throws VeryImportantException {
throw new VeryImportantException();
}
void dispose() throws HoHumException {
throw new HoHumException();
}
void eliminate() throws MeaninglessException {
throw new MeaninglessException();
}
public static void main(String[] args) {
try {
LostMessage18 lm = new LostMessage18();
try {
try {
lm.f();
lm.dispose();
} finally {
lm.eliminate();
}
} catch(Exception e) {
System.out.println(e);
}
} catch(Exception e) {
System.out.println(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -