public class AssertDemo
{
public static void main(String[] args) {
int x = 10;
assert x== 100;
System.out.println(x);
}
}
java -ea AssertDemo // 需要特定环境下执行
Exception in thread "main" java.lang.AssertionError: x的数值不是100
at AssertDemo.main(AssertDemo.java:5)