e105. handling an assertion error.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 16 行
TXT
16 行
When an assertion fails, AssertionError is thrown. Handling an assertion failure is rarely done. A situation in which you might handle an assertion failure is in the top-level loop of a high-availability server.
try {
assert args.length > 0;
} catch (AssertionError e) {
// In this case, the message is null
String message = e.getMessage();
}
try {
assert args.length > 0 : "my message";
} catch (AssertionError e) {
// In this case, the message is a string
String message = e.getMessage();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?