断言在默认情况下是关闭的,要在编译时启用断言,

只要给eclipse相应的jre中增加一个参数即可

eclipse中最简单使用assert的配置


可以根据以下代码判断断言是否打开:

 public class AssertExampleTwo{

   public static void main(String args[]){
     boolean isEnable=false;
     //...
     assert isEnable=true;//如果未打开,就不会执行该语句
     if(isEnable==false){
       throw new RuntimeException("Assertion shoule be enable!");
     }
   }
}

转载于:https://my.oschina.net/beanGo/blog/184282

相关文章:

  • 2021-05-16
  • 2021-11-02
  • 2021-05-02
  • 2021-07-05
  • 2021-10-18
  • 2021-06-16
  • 2021-11-13
猜你喜欢
  • 2021-05-29
  • 2021-06-16
  • 2021-11-01
  • 2021-09-17
  • 2021-11-28
  • 2021-06-22
  • 2022-01-08
相关资源
相似解决方案