您当前的位置: 首页 > 

zmc@

暂无认证

  • 2浏览

    0关注

    142博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

assert注意事项

zmc@ 发布时间:2021-10-08 11:33:38 ,浏览量:2

结论:

直接使用 assert field != null; 可以快速的check属性,但是该方法会在使用反射的时候多一个属性

"$assertionsDisabled"

分析:

public class Assert {
  static final boolean $assertionsDisabled =
    !Assert.class.desiredAssertionStatus();
  public static void main(String[] args) {
    if (!$assertionsDisabled) {
      if (System.currentTimeMillis() != 0L) {
        throw new AssertionError();
      }
    }
  }
}

 

关注
打赏
1643271353
查看更多评论
立即登录/注册

微信扫码登录

0.0363s