JAVA断言-assert
2019-11-04 本文已影响0人
咯噔ya
断言是为了方便调试程序,并不是发布程序的组成部分。
1.开启断言
VM options配置 -ea

2.断言有两种定义方式:
1)assert false : "Not safe at all";
运行结果:

2)
assert false;
运行结果:

区别就是第一种可以输出具体报错信息。
VM options配置 -ea
1)assert false : "Not safe at all";
运行结果:
assert false;