阅读612 返回首页    go 阿里云 go 技术社区[云栖]


Java之dead code——无用代码

dead code无作用的代码
  if (true & true) {
   System.out.println("execute ok");
  } else {
   System.out.println("execute fail");
  }
从else开始即为无作用。因为true&true在编绎时即知结果,所以else部分是无用的,编译器知道肯定不会执行的代码。


boolean a = true;
  boolean b = true;
  if (a & b) {
   System.out.println("execute ok");
  } else {
   System.out.println("execute fail");
  }
不会出现该问题,因为在编译时编译器不确定a & b是否恒成立。

 

原帖地址:https://hi.baidu.com/nicker2010/item/c00c521f01f1eeaffeded596

最后更新:2017-04-03 16:49:10

  上一篇:go SplishActivity的作用
  下一篇:go Oracle中Lpad函数和Rpad函数的用法