Java之dead code——无用代码

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

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是否恒成立。

 

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

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/hdsghtj/article/details/84024469