日期:2014-05-20  浏览次数:20652 次

关于boolean变量默认值问题
public class test{
  boolean end;
  public void aa(){
  if(end){
  .........;
  }
  }
其中的if(end)
应该怎么理解?
还有boolean end; end的默认值是什么?

------解决方案--------------------
public void aa(){ 
 boolean end; 
//如果end=true时就执行if中的代码
if(end){ 
.........; 


end默认值是false
------解决方案--------------------
手误 isLeapYear == true !!
Java code

boolean isLeapYear = false;
if(isLeapYear) // 这里等同于 isLeapYear == true  不过一般都这样简写了,效率更高
  System.out.print("闰年");
else
  System.out.print("不是闰年")