assert keyword, its main function is to assert, assert that after the implementation of the program refers to a row, the result must be the expected result
Example: Using observation assertions
package cn.mldn.demo;
public class JavaDemo {
public static void main(String args[]) throws Exception {
int x = 10;
// 中间可能会经过许多条程序语句,导致变量x的内容发生改变
assert x == 100 : "x的内容不是100";
System.out.println(x);
}
}
启用affirm:
Java -Ea Cn.Mldn.Demo.JavaDemo