class jj{
public static void main(String arg[]){
boolean a=true;
boolean b=false;
boolean c=true;
if(a==true)
if(b==true)
if(c==true)
System.out.println("some things are true in this world");
else 
System.out.println("nothing is true in this world");
else if(a&&(b=c))
System.out.println("it's top confusing to tell what is true and what is false");
else
System.out.println("hey this won't compile");

}
}

解决方案 »

  1.   

    class jj {
    public static void main(String arg[]) {
    boolean a = true;
    boolean b = false;
    boolean c = true;
    if (a == true)
    if (b == true)
    if (c == true)
    System.out.println("some things are true in this world");
    else
    System.out.println("nothing is true in this world");
    else if (a && (b = c))
    System.out
    .println("it's top confusing to tell what is true and what is false");
    else
    System.out.println("hey this won't compile"); }
    }
      

  2.   

    你可以把它放到eclipse中格式化以下,就可以看清楚其对应关系。
      

  3.   

    中间的if和下面的else是一组
    1-if
    2-if
    3-if
    3-else
    2-else
    1-else
    就这个判断顺序
    eclipse格式化好工具,楼上提到了,再提一次,可以让代码格式规范化
      

  4.   

    if (a == true){
    if (b == true){
    if (c == true){
    System.out.println("some things are true in this world");
    } else {
    System.out.println("nothing is true in this world");
    }
    } else {
    if (a && (b = c)){
    System.out.println("it's top confusing to tell what is true and what is false");
    } else {
    System.out.println("hey this won't compile");
    }
    }
    }
      

  5.   

    我来说个规则吧
    else总与上边未配对的if答配
    新手总是容易出这种错误
    建议最好使用IF elseif  else
    这种形式就不会犯这种低级错误