idea使用断言

测试程序

public class TestAssert {
    public static void main(String[] args) {
        String s1 = null;
        assert s1 != null; // 默认assert不起作用, 需开启-ve参数
        System.out.println("test assert");
    }
}

开启assert检查