提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
检查是否启用断言的程序
/*来自 N o w J a v a . c o m*/ public class Main { public static void main(String[] args) { boolean enabled = false; assert enabled = true; if (enabled) { System.out.println("Assertion is enabled."); } else { System.out.println("Assertion is disabled."); } } }