public static void test(int n){
assert n >= 0;
System.out.println(n);
}
public static void main(String[] args){
test(-1);
}
程序运行没有报错,后来知道需要去开启断言
进入Edit configurations
在VM options 添加“-ea”
运行程序报错
Exception in thread "main" java.lang.AssertionError
at com.wangzhou.datastructure.graph.DenseGraph.test(DenseGraph.java:19)
at com.wangzhou.datastructure.graph.DenseGraph.main(DenseGraph.java:24)