exceptionsampler.java
来自「< ProJavaProgrammingSecondEdition>」· Java 代码 · 共 24 行
JAVA
24 行
public class ExceptionSampler {
/**
* Not declaring that this method can throw MyFirstException will
* cause the Java compiler to generate an error message when this
* class is compiled. However, declaring MySecondException is
* optional.
*/
public void doSomething(boolean throwFirst) throws MyFirstException {
if (throwFirst) {
throw new MyFirstException();
} else {
throw new MySecondException();
}
}
class MyFirstException extends Exception {
}
class MySecondException extends RuntimeException {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?