7黑马币
最佳答案语法:
assert
assert :
当boolean表达式为false时,抛出AssertError,程序终止运行。
例子:
Java code
public class Cloned {
public static void main(String[] args) {
System.out.println("classes");
try{
//when running as java -ea Cloned -5, it's supposed to throw AssertError;
assert (Integer.parseInt(args[0]) > 0):"assertTest";
}catch ...
| |
| |
| |
| |
| |