int a=10, b=5;
if(a>b)
{
if(b>5)
System.out.println("b is:"+b);
}
else
System.out.println("a is:"+a");
}
Run Code Online (Sandbox Code Playgroud)
此代码在运行时没有显示输出,为什么?
您的代码段注释:
int a=10, b=5;
if(a>b) // is true (10>5)
{
if(b>5) // is false (5>5)
System.out.println("b is:"+b);
// no else case, so does nothing
}
else // never gets here
System.out.println("a is:"+a");
} // unmatched bracket
Run Code Online (Sandbox Code Playgroud)
确保完整代码中没有语法错误(如无法匹配的括号),并且始终存在其他情况,仅用于开发目的.